mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
19 lines
282 B
C++
19 lines
282 B
C++
|
#include<stdio.h>
|
||
|
int gcd(int x,int y)
|
||
|
{
|
||
|
return y==0?x:gcd(y,x%y);
|
||
|
}
|
||
|
int main()
|
||
|
{
|
||
|
int a,b,c,t;
|
||
|
scanf("%d",&t);
|
||
|
while(t--)
|
||
|
{
|
||
|
scanf("%d%d",&a,&b);
|
||
|
c=b+b;
|
||
|
while(gcd(a,c)!=b)
|
||
|
c+=b;
|
||
|
printf("%d\n",c);
|
||
|
}
|
||
|
}
|