QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#808461#9868. GCDlbssssssWA 0ms3664kbC++17639b2024-12-10 20:54:552024-12-10 20:55:01

Judging History

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

  • [2024-12-10 20:55:01]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3664kb
  • [2024-12-10 20:54:55]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'