QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#547283 | #6510. Best Carry Player 3 | rotcar07 | WA | 1ms | 3552kb | C++14 | 672b | 2024-09-04 20:09:14 | 2024-09-04 20:09:14 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;cin>>t;
while(t--){
typedef long long ll;
ll a,b,k;cin>>a>>b>>k;
if(!k){
cout<<labs(a-b)<<'\n';
continue;
}
int z=__lg(k)+1;
if(a>b) swap(a,b);
ll w=(1ll<<z)-1;
ll ans=0;
if((a>>z)!=(b>>z)){
if((a&w)==w) ans++;
else if((~a&w)<=k)ans+=2;
else ans+=3;
ans+=((b>>z)-(a>>z)-1)*(2+(k!=w));
a=b>>z<<z;
}
if(a==b);else
if((a^b)<=k) ans++;
else ans+=2;
cout<<min(b-a,ans)<<'\n';
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3552kb
input:
8 4 5 0 5 8 3 9 2 6 15 28 5 97 47 8 164 275 38 114514 1919 810 0 1152921504606846975 1
output:
1 0 1 4 1 6 331 1
result:
wrong answer 2nd numbers differ - expected: '2', found: '0'