QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#838787#9868. GCDTangWKWA 0ms3472kbC++20738b2024-12-31 22:34:522024-12-31 22:34:54

Judging History

你现在查看的是最新测评结果

  • [2024-12-31 22:34:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3472kb
  • [2024-12-31 22:34:52]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve() {
    i64 a, b;
    cin >> a >> b;
    const int ti = 20;
    int ans = 30;
    function<void(i64,i64,int)> dfs = [&](i64 x,i64 y, int step) {
        if (x == 0 || y == 0) {
            ans = min(ans, step);
            return;
        }
        if (step >= ti) {
            return;
        }
        i64 g = gcd(x, y);
        dfs(x - g, y, step + 1);
        dfs(x, y - g, step + 1);
        return;
    };
    dfs(a, b, 0);
    cout << ans << "\n";
    return;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3472kb

input:

3
3 4
12 20
114 514

output:

2
3
5

result:

wrong answer 1st lines differ - expected: '3', found: '2'