QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#547283#6510. Best Carry Player 3rotcar07WA 1ms3552kbC++14672b2024-09-04 20:09:142024-09-04 20:09:14

Judging History

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

  • [2024-09-04 20:09:14]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3552kb
  • [2024-09-04 20:09:14]
  • 提交

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

Details

Tip: Click on the bar to expand more detailed information

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'