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: 8ms
Memory: 1092kB
Author: Sugar
In contest: 1141

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