QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#361056#6510. Best Carry Player 3Core_65536WA 0ms3612kbC++20997b2024-03-22 18:46:322024-03-22 18:46:33

Judging History

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

  • [2024-03-22 18:46:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3612kb
  • [2024-03-22 18:46:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

void solve()
{
    int x,y,k;  cin>>x>>y>>k;
    if(x>y) swap(x,y);
    int len=0;
    int tmp=k;
    while(tmp!=0)
    {
        len++;
        tmp=tmp>>1;
    }
    int xl,xr,yl,yr;
    xl=x>>len;  xr=x-(xl<<len);
    yl=y>>len;  yr=y-(yl<<len);
    int m=3;    
    if(k==(1<<len)-1)   m=2;
    int t=m*(yl-xl-1);
    int a=((~xr)>k)?3:2;
    if(xr==((1<<len)-1))    a=1;
    int b=(yr>k)?2:1;
    if(yr==0)   b=0;
    int ans=t+a+b;
    if(x==0)    a=1;
    if(y==0)    b=0;
    if(k==1||k==0)    ans=(y-x);
    int cnt=0;
    for(int i=0;i<61;i++){
        if(((x>>i)&1)!=((y>>i)&1)){
            cnt+=1<<i;
        }
    }
    if(cnt<=k)  ans=1;
    if(x==y)  ans=0;
    //cout<<t<<" "<<a<<" "<<b<<endl;

    cout<<ans<<endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T=0;    cin>>T;
    while(T--)  solve();
    return 0;
}

详细

Test #1:

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

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
2
3
5
11
6
331
1

result:

wrong answer 8th numbers differ - expected: '1152921504606846975', found: '1'