QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#360186 | #6510. Best Carry Player 3 | HanZhongBalls# | WA | 0ms | 3932kb | C++14 | 1.6kb | 2024-03-21 14:39:58 | 2024-03-21 14:40:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
#define F first
#define S second
#define random(x) (rand() % (x))
#define LOG(a, b) (log(a) / log(b))
#define N 2000005
#define mod 998244353
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3fll
ull x,y,k,lk,rk,a,cnt;
int main(){
int T;scanf("%d",&T);
while(T--){
scanf("%llu%llu%llu",&x,&y,&k);
if(k<=1){
if(x>y) swap(x,y);
printf("%llu\n",y-x);
continue;
}
if(x==y){puts("0");continue;}
for(rk=0;(1ull<<rk)<=k;++rk){}rk=(1ull<<rk-1);
for(lk=0;(1ull<<lk)<=k+1;++lk){}lk=(1ull<<lk-1)-1;
printf("%llu %llu\n",lk,rk);
cnt=0;
if(lk>=rk){
a=(x^y);if(a<=k){puts("1");continue;}
if(y==x+1||x==y+1){puts("1");continue;}
if(x>y) swap(x,y);
cnt=1;
if((x&lk)!=lk) ++cnt,x=(x|lk);
++x;
if((y&lk)!=0) ++cnt,y=(y&(~lk));
printf("%llu\n",(y-x)/(lk+1ull)*2ull+cnt);
continue;
}
a=(x^y);if(a<=k){puts("1");continue;}
if(y==x+1||x==y+1){puts("1");continue;}
if(a<=rk+lk){puts("2");continue;}
cnt=0;
if(x>y) swap(x,y);
if((x&(lk+rk))==lk+rk) ++cnt;
else if(lk+rk-(x&(lk+rk))<=k) cnt+=2;
else cnt+=3;
x=(x|(lk+rk))+1;
//printf("%llu\n",cnt);
if((y&(lk+rk))==0) cnt=cnt;
else if((y&(lk+rk))<=k) ++cnt;
else cnt+=2;
//printf("%llu\n",cnt);
y=y&(~(lk+rk));
printf("%llu\n",(y-x)/(lk+rk+1ull)*3ull+cnt);
}
return 0;
}
/*
9
4 5 0
5 8 3
9 2 6
15 28 5
97 47 8
164 275 38
114514 1919 810
0 1152921504606846975 1
164 275 31
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3932kb
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 3 2 2 3 4 3 3 4 5 7 8 11 31 32 6 511 512 331 1152921504606846975
result:
wrong answer 2nd numbers differ - expected: '2', found: '3'