Problem 1000
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 9 Solved: 2
[Submit][Status][Web Board]
Description
一天Lvsi得到了一个方程 ax+by=d,已知a,b。a,b,x,y均为整数d为正整数 他突发奇想符合条件的d的最小正整数是什么呢?经过一番思考,他得到了答案,但是他在想d的正整数解中第n大的是什么呢?Lvsi苦思了好久都想不出,相信聪明的你能帮他解决。Just ac it。
Input
输入有多组测试数据,每行为一组,每组三个数a,b,n。 0 <= a ,b <= 10^7;
Output
对于每组测试,请输出一个答案。每两个测试样例之间空一行。
Sample Input
20320 23236 361
2456 12488 358
Sample Output
1444
2864
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 9 Solved: 2
[Submit][Status][Web Board]
Description
一天Lvsi得到了一个方程 ax+by=d,已知a,b。a,b,x,y均为整数d为正整数 他突发奇想符合条件的d的最小正整数是什么呢?经过一番思考,他得到了答案,但是他在想d的正整数解中第n大的是什么呢?Lvsi苦思了好久都想不出,相信聪明的你能帮他解决。Just ac it。
Input
输入有多组测试数据,每行为一组,每组三个数a,b,n。 0 <= a ,b <= 10^7;
Output
对于每组测试,请输出一个答案。每两个测试样例之间空一行。
Sample Input
20320 23236 361
2456 12488 358
Sample Output
1444
2864
标程:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int gcd(int a,int b)
{
if(b==0) return a;
int r=b;
while(r)
{
r = a%b;
a=b;
b=r;
}
return a;
}
int main()
{
int a,b,c;
while(scanf("%d%d%d",&a,&b,&c)!=EOF)
{
int d=gcd(a,b);
printf("%d\n\n",d*c);
}
return 0;
}