QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#805461#9869. Horizon ScanningLittleXi#WA 0ms3948kbC++11727b2024-12-08 16:49:042024-12-08 16:49:07

Judging History

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

  • [2024-12-08 16:49:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3948kb
  • [2024-12-08 16:49:04]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define endl "\n"
#define ll long long

ll upper;
ll ans = 0;
void dfs(ll a,ll b,ll dp){
    if(a == 0 && b == 0){
        ans = min(ans , dp);
        return;
    }
    if(dp > upper || dp > ans || a < 0 || b < 0) return;
    ll g = __gcd(a,b);
    if(a/g%2==1){
        dfs(a-g,b,dp+1);
        dfs(a,b - g,dp+1);
    }else{
        dfs(a,b - g,dp+1);  
        dfs(a-g,b,dp+1);
    }
}

void solve(){
    ll a,b;cin>>a>>b;
    upper = log2(a);
    upper = upper * 2 + 1;
    ans = 1e9;
    dfs(a,b,0);
    cout<<ans<<endl;

}

int main(){
    cin.tie(0);cout.tie(0);
    ios::sync_with_stdio(0);
    ll t;cin>>t;while(t--)
    solve();
}

詳細信息

Test #1:

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

input:

5
1 1
0 1
8 2
1 0
1 1
0 1
-1 1
-1 0
-1 -1
0 -1
1 -1
4 2
-1 1
0 1
0 2
1 1
4 2
-1000000000 0
-998244353 1
998244353 1
1000000000 0
3 1
0 1
0 2
0 -1

output:

2
1
2
1
2

result:

wrong answer 1st numbers differ - expected: '6.2831853', found: '2.0000000', error = '0.6816901'