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

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