QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#808461 | #9868. GCD | lbssssss | WA | 0ms | 3664kb | C++17 | 639b | 2024-12-10 20:54:55 | 2024-12-10 20:55:01 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
int sol(int a,int b){
// std::cerr << a << ' ' << b << '\n';
if(a==0 && b==0)return 0;
if(a==0||b==0)return 1;
int g = std::gcd(a,b);
int k1 = a / g, k2 = b / g;
int res = k2-k1+2;
if(k1==1){
res = std::min(res, sol(0,b)+1);
}
if(k1%2){
res = std::min(res,sol(a-g,b)+1);
}
return sol(a,b-g)+1;
}
void solve(){
int a,b;
std::cin >> a >> b;
std::cout<<sol(a,b)<<"\n";
}
signed main(){
int t = 1;
std::cin >> t;
while(t--)solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3664kb
input:
3 3 4 12 20 114 514
output:
3 4 16
result:
wrong answer 3rd lines differ - expected: '6', found: '16'