QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#838787 | #9868. GCD | TangWK | WA | 0ms | 3472kb | C++20 | 738b | 2024-12-31 22:34:52 | 2024-12-31 22:34:54 |
Judging History
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'