zoukankan      html  css  js  c++  java
  • 训练1-V

    输入2个正整数A,B,求A与B的最大公约数。

    Input
    2个数A,B,中间用空格隔开。(1<= A,B <= 10^9)
    Output
    输出A与B的最大公约数。
    Sample Input
    30 105
    Sample Output
    15
    #include<stdio.h>                    //水题,用欧几里得算法
    int main()
    {
    	int GCD(int a,int b);
    	int A,B;
    	scanf("%d%d",&A,&B);
    	printf("%d
    ",GCD(A,B));
    	return 0;
    }
    
    int GCD(int a,int b)             //大家最好记住这个模板,不知道算法的可以百度
    {
    	return b==0?a:GCD(b,a%b);
    }

    ...

  • 相关阅读:
    term "JavaScript"
    Pro Git
    Pro Git
    Pro Git
    git
    flask
    OJ
    [蓝桥杯]Huffuman树
    priority_queue优先队列
    [蓝桥杯]高精度加法
  • 原文地址:https://www.cnblogs.com/aerer/p/9931097.html
Copyright © 2011-2022 走看看