Start: Mar, 06, 2018 09:46:00
计算机161 算法分析与设计 第一次实验课作业(吴银杰、张凯庆)
End: Mar, 10, 2018 10:00:00
Time elapsed:
Time remaining:

Problem_ID: D
Result: Accepted
Time: 4ms
Memory: 1092kB
In contest: 1141

#include<stdio.h>
int gcd(int a,int b){
    return b==0?a:gcd(b,a%b);
}
int main(){
 
   int n;
    scanf("%d",&n);
    int a,b,c,i;
    while(n--){
        scanf("%d%d",&a,&b);
        for(i=2;i<=1000000;i++)
            if(gcd(a/b,i)==1){
                c=i*b;
                break;
            }
        printf("%d\n",c);
    }
    return 0;
}