hdu 2504

注解:水题,直接暴力枚举过,代码如下:
#include<iostream>
#include<cstring>

using namespace std;

typedef long long ll;

ll fun(ll x,ll y)
{
	ll tmp;
	
	if(x < y)
	{
		tmp = x;
		x = y;
		y = tmp;
	}
	
	while(y)
	{
		tmp = x % y;
		x = y;
		y = tmp;
	}
	
	return x;
}

int main()
{
   ll a,b,c;
   int n;
   
   cin>>n;
   while(n--)
   {
   	cin>>a>>b;
   	c = b+1;
   	while(fun(a,c) != b)
   	     c++;
    cout<<c<<endl;
   }
   
   return 0;
	
}

阅读更多

没有更多推荐了,返回首页