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: 1712kB
Author: 2017212212283
In contest: 1141

#include <iostream>
#include <cstdio>

using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	while(n--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		int i=2;
		while(1)
		{
			if(a%(i*b)==0)
				i++;
			else
			{
				cout<<i*b<<endl;
				break;
			}
		}
	}
	return 0;
}