Problem 1000

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


标程:

#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; 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值