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
Author: 2016210401006
In contest: 1141

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