QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#805461 | #9869. Horizon Scanning | LittleXi# | WA | 0ms | 3948kb | C++11 | 727b | 2024-12-08 16:49:04 | 2024-12-08 16:49:07 |
Judging History
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'