GCDwronganswer了,24行代码递归
查看原帖
GCDwronganswer了,24行代码递归
105820
阿尔托莉雅丶楼主2021/3/3 23:52
#include <iostream>
#include <algorithm>
using namespace std;

long long a, b;
long long gcd(long long x, long long y)
{
    if(x % y == 0)
        return x;
    else
        return gcd(y, x % y) + x / y * y;
}

int main(void)
{
    cin >> a >> b;

    if(a < b)
        swap(a, b);

    cout << gcd(a, b) * 4;

    return 0;
}
2021/3/3 23:52
加载中...