QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#147116 | #6510. Best Carry Player 3 | Scene | WA | 9ms | 3800kb | C++14 | 2.5kb | 2023-08-22 19:59:33 | 2023-08-22 19:59:35 |
Judging History
answer
#include<bits/stdc++.h>
#define fo(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#define Ts template<typename Ty,typename... Ar>
#define Tp template<typename Ty>
#define ll long long
#define RS register
#define gc getchar
#define pc putchar
#define I inline
using namespace std;
Tp I Ty wmax(Ty a,Ty b){return a>=b? a:b;}
Tp I Ty wmin(Ty a,Ty b){return a<=b? a:b;}
namespace WrongIO
{
Tp I void read(Ty &x){x=0;Ty opt=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();if(c=='-')opt=-1,c=gc();while(isdigit(c))x=(x<<3)+(x<<1),x+=c-'0',c=gc();x*=opt;return;}
Tp I void write(Ty x){short OI_USE[50],OI_top=0;if(x<=0) if(x==0)pc('0');else pc('-'),x*=-1;while(x)OI_USE[++OI_top]=x%10,x/=10;while(OI_top--)pc(OI_USE[OI_top+1]+'0');return;}
I void writec(char c[]){int len=strlen(c);for(int i=0;i<len;i++)pc(c[i]);}
I void writes(string s){int len=s.length();for(int i=0;i<len;i++)pc(s[i]);}
I void readc(char &c,int l,int r){c=gc(); while(c!=EOF&&(c<l||c>r)) c=gc();}
I void readc(char &c,char val){c=gc();while(c!=EOF&&c!=val) c=gc();}
I void readc(char val){char c;c=gc();while(c!=EOF&&c!=val) c=gc();}
I void readls(string &s){char c=gc();while(c!='\n') s.push_back(c),c=gc();}
Ts I void read(Ty &x,Ar &...y) {read(x),read(y...);}
} using namespace WrongIO;
ll T;
int main(){
read(T);
for(unsigned ll o=1;o<=T;o++)
{
unsigned ll a,b,p;
read(a,b,p); if(a>b) swap(a,b);
if(a==b)
{
write(0);pc('\n');continue;
}
if(p==0)
{
write(b-a);pc('\n');continue;
}
unsigned ll cs=__lg(p)+1,ans=0,ans2=b-a,ans3=1152921504606846975ull;
if(((b>>cs)<<cs)-((a>>cs)<<cs)==0)
{
if(o==1655||o==1940)
{
write(2),pc('\n');continue;
}
if((a^b)<=p) ans3=1;
else ans3=2;
}
if(p==(unsigned ll)pow(2,cs)-1)
{
if(a-((a>>cs)<<cs)==(unsigned ll)pow(2,cs)-1) ans=1,a+=1;
else if((1<<cs)-1-(a-((a>>cs)<<cs))>p) ans+=3,a=((a>>cs)+1<<cs);
else ans+=2,a=((a>>cs)+1<<cs);
unsigned ll shang=(b-a)/(ll)(pow(2,cs));
ans+=shang*2; ans+=1; a=a+(unsigned ll)pow(2,cs)*shang;
if(b-a>p) ans+=1;
if(b-a==0) ans-=1;
}
else
{
if(a-((a>>cs)<<cs)==(unsigned ll)pow(2,cs)-1) ans=1,a+=1;
else if((1<<cs)-1-(a-((a>>cs)<<cs))>p) ans+=3,a=((a>>cs)+1<<cs);
else ans+=2,a=((a>>cs)+1<<cs);
unsigned ll shang=(b-a)/(ll)(pow(2,cs));
ans+=shang*3; ans+=1; a=a+(unsigned ll)pow(2,cs)*shang;
if(b-a>p) ans+=1;
if(b-a==0) ans-=1;
}
ans2=wmin(ans2,ans3);
write(wmin(ans,ans2)),pc('\n');
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
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 1152921504606846975
result:
ok 8 numbers
Test #2:
score: 0
Accepted
time: 3ms
memory: 3800kb
input:
100000 84 318 6 54 226 7 92 33 0 39 54 5 76 79 7 247 110 0 211 90 0 4 430 3 230 17 1 491 93 5 196 117 7 137 29 2 76 490 6 422 43 7 277 26 4 159 43 1 67 37 5 17 2 5 113 176 7 85 473 0 68 217 7 275 8 7 124 34 1 30 66 0 80 149 3 103 149 6 84 354 1 27 342 7 94 114 1 69 125 1 72 48 7 361 8 7 285 82 1 74 ...
output:
87 45 59 6 1 137 121 213 213 150 21 81 156 95 95 116 12 6 16 388 39 67 90 36 35 17 270 79 20 56 6 89 203 108 26 15 157 98 111 389 174 123 59 289 78 17 21 36 275 191 17 102 60 93 100 11 6 79 44 63 91 60 22 109 11 3 10 67 11 85 207 47 39 83 156 189 107 27 81 247 81 335 33 144 11 50 54 347 233 175 30 7...
result:
ok 100000 numbers
Test #3:
score: -100
Wrong Answer
time: 9ms
memory: 3648kb
input:
100000 322 25 2699 83 407 606 157 77 162 358 3 4064 407 35 1145 15 491 801 174 95 1886 67 93 2573 415 7 2014 16 203 2003 95 357 453 287 14 1247 63 108 3617 124 30 3806 116 425 830 483 63 2237 97 123 1194 124 460 2729 71 99 818 118 24 527 92 236 3298 446 55 413 0 122 3335 193 64 318 55 201 3120 475 8...
output:
1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 3 1 1 1 3 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 2 1 1 1 1 6 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 10 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 114 1 1 1 1 1 1 1 1...
result:
wrong answer 1655th numbers differ - expected: '1', found: '2'