题目传送门

#include <bits/stdc++.h>

using namespace std;
typedef long long LL;
LL x, y, ans;

//辗转相除法
LL gcd(LL a, LL b) {
    if (b == 0) return a;
    ans += 4 * b * (a / b);
    return gcd(b, a % b);
}

int main() {
    cin >> x >> y;
    gcd(x, y);
    printf("%lld\n", ans);
    return 0;
}

相关文章:

  • 2021-05-30
  • 2021-09-24
  • 2021-04-10
  • 2021-12-04
  • 2021-05-01
  • 2021-08-06
  • 2021-08-12
  • 2021-10-30
猜你喜欢
  • 2021-11-18
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2021-08-13
  • 2021-08-05
  • 2022-12-23
相关资源
相似解决方案