QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#849502 | #9878. A xor B plus C | Wuyanru | AC ✓ | 1153ms | 79744kb | C++14 | 2.5kb | 2025-01-09 15:52:11 | 2025-01-09 15:52:11 |
Judging History
answer
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f3f3f3f3fll
#define debug(x) cerr<<#x<<"="<<x<<endl
using namespace std;
using ll=long long;
using ld=long double;
using pli=pair<ll,int>;
using pi=pair<int,int>;
template<typename A>
using vc=vector<A>;
template<typename A,const int N>
using aya=array<A,N>;
inline int read()
{
int s=0,w=1;char ch;
while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
inline ll lread()
{
ll s=0,w=1;char ch;
while((ch=getchar())>'9'||ch<'0') if(ch=='-') w=-1;
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;
}
const int mod=998244353;
ll X[2000005];
int S[3];
int A,B,C;ll n;
inline ll wtf(ll n,ll d)
{
return (n-3)%d+3;
}
int main()
{
A=read(),B=read(),C=read(),n=lread();
if(n<=2){ printf("%d\n",n==1?A:B);return 0;}
ll ans=0,now;int M=1;
while(max(max(A,B),C)>=(1<<M)) M++;
//先维护 <M 的序列
X[1]=A,X[2]=B;vc<ll>Y;
for(int i=3;i<3+3*(1<<(M-1));i++)
{
X[i]=(X[i-1]^X[i-2])+C;
if(X[i]>=(1<<M)) X[i]-=1<<M,Y.push_back(i);
}
ll len=3*(1<<(M-1));
ans=X[wtf(n,len)];now=1<<(M-1);
// printf("M=%d len=%lld ans=%lld\n",M,len,ans);
// printf("wtf %lld %lld : %lld\n",n,len,wtf(n,len));
// for(ll i:Y) printf("%lld ",i);;putchar('\n');
while(Y.size())
{
if(len<n)//推出这一位的所有 Y
{
vc<ll>lst;
for(ll i:Y) lst.push_back(i);
for(ll i:Y) lst.push_back(i+len);
Y.clear();
S[0]=S[1]=S[2]=0;
ll xw=wtf(n,2*len);int xn=0;
for(ll i:lst)
{
if(S[i%3]^S[(i-1)%3]) Y.push_back(i);
if(i<=xw&&(xw-i)%3!=2) xn^=1;
S[i%3]^=1;
}
len<<=1,now=(now*2)%mod;
if(xn) ans=(ans+now)%mod;
}
else
{
vc<ll>lst;
for(ll i:Y) lst.push_back(i);
Y.clear();
S[0]=S[1]=S[2]=0;
ll xw=n;int xn=0;
for(ll i:lst)
{
if(S[i%3]^S[(i-1)%3]) Y.push_back(i);
if(i<=xw&&(xw-i)%3!=2) xn^=1;
S[i%3]^=1;
}
now=(now*2)%mod;
if(xn) ans=(ans+now)%mod;
}
// printf("%d : %d\n",M++,(int)Y.size());
}
printf("%lld\n",ans);
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3676kb
input:
1 2 3 4
output:
7
result:
ok "7"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3760kb
input:
123 456 789 123456789
output:
567982455
result:
ok "567982455"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
0 0 0 1000000000000000000
output:
0
result:
ok "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3752kb
input:
628 314 157 1
output:
628
result:
ok "628"
Test #5:
score: 0
Accepted
time: 0ms
memory: 4108kb
input:
167 924 167 2
output:
924
result:
ok "924"
Test #6:
score: 0
Accepted
time: 0ms
memory: 17096kb
input:
1048575 1048575 1048575 1000000000000000000
output:
1048575
result:
ok "1048575"
Test #7:
score: 0
Accepted
time: 1132ms
memory: 79500kb
input:
287144 758614 992207 1000000000000000000
output:
638555367
result:
ok "638555367"
Test #8:
score: 0
Accepted
time: 1038ms
memory: 78812kb
input:
442510 534717 936857 1000000000000000000
output:
125005501
result:
ok "125005501"
Test #9:
score: 0
Accepted
time: 1121ms
memory: 78252kb
input:
507590 985947 1025549 999999999999999833
output:
363289377
result:
ok "363289377"
Test #10:
score: 0
Accepted
time: 1139ms
memory: 78604kb
input:
989414 986755 1024915 1000000000000000000
output:
176552525
result:
ok "176552525"
Test #11:
score: 0
Accepted
time: 865ms
memory: 76332kb
input:
773910 981383 748815 999999999999999372
output:
712048477
result:
ok "712048477"
Test #12:
score: 0
Accepted
time: 625ms
memory: 52656kb
input:
539000 982202 549877 1000000000000000000
output:
49295427
result:
ok "49295427"
Test #13:
score: 0
Accepted
time: 921ms
memory: 76320kb
input:
930318 901108 790115 999999999999999002
output:
446688556
result:
ok "446688556"
Test #14:
score: 0
Accepted
time: 1109ms
memory: 78816kb
input:
57298 210381 985237 1000000000000000000
output:
533555472
result:
ok "533555472"
Test #15:
score: 0
Accepted
time: 294ms
memory: 34924kb
input:
567956 1013479 284068 1000000000000000000
output:
13855344
result:
ok "13855344"
Test #16:
score: 0
Accepted
time: 1153ms
memory: 77824kb
input:
694266 795841 967344 1000000000000000000
output:
179712105
result:
ok "179712105"
Test #17:
score: 0
Accepted
time: 280ms
memory: 34080kb
input:
744515 402386 261828 1000000000000000000
output:
915814204
result:
ok "915814204"
Test #18:
score: 0
Accepted
time: 123ms
memory: 26008kb
input:
630928 108751 103226 1000000000000000000
output:
314920156
result:
ok "314920156"
Test #19:
score: 0
Accepted
time: 627ms
memory: 55900kb
input:
408870 219543 576432 1000000000000000000
output:
332612604
result:
ok "332612604"
Test #20:
score: 0
Accepted
time: 1094ms
memory: 79744kb
input:
208613 769277 1010542 819875140559301752
output:
110220300
result:
ok "110220300"
Test #21:
score: 0
Accepted
time: 419ms
memory: 48552kb
input:
123844 719656 377241 520974001002628387
output:
986512272
result:
ok "986512272"
Test #22:
score: 0
Accepted
time: 955ms
memory: 77112kb
input:
774205 820111 841396 711066335916901718
output:
254873758
result:
ok "254873758"
Test #23:
score: 0
Accepted
time: 1050ms
memory: 79232kb
input:
604531 395365 966071 999594448264125858
output:
505142123
result:
ok "505142123"
Test #24:
score: 0
Accepted
time: 1024ms
memory: 78572kb
input:
59523 598376 922420 752304351201620672
output:
351022203
result:
ok "351022203"
Test #25:
score: 0
Accepted
time: 1065ms
memory: 77160kb
input:
192450 176925 1037973 192583019203393748
output:
56600397
result:
ok "56600397"
Test #26:
score: 0
Accepted
time: 1078ms
memory: 78648kb
input:
972801 523798 994144 594688603126478507
output:
750534499
result:
ok "750534499"
Test #27:
score: 0
Accepted
time: 0ms
memory: 17968kb
input:
669131 939565 629 543390474884493567
output:
652889135
result:
ok "652889135"
Test #28:
score: 0
Accepted
time: 440ms
memory: 49344kb
input:
829091 688584 371532 935387048229453232
output:
784327643
result:
ok "784327643"
Test #29:
score: 0
Accepted
time: 152ms
memory: 20044kb
input:
407113 311573 150840 428344291461283594
output:
486756568
result:
ok "486756568"
Test #30:
score: 0
Accepted
time: 329ms
memory: 36556kb
input:
338931 949581 280744 289664704872449795
output:
459928211
result:
ok "459928211"
Test #31:
score: 0
Accepted
time: 507ms
memory: 44040kb
input:
16277 434162 426083 575309380820099707
output:
927534514
result:
ok "927534514"
Test #32:
score: 0
Accepted
time: 577ms
memory: 53704kb
input:
669467 627218 559817 371026815047584891
output:
393999810
result:
ok "393999810"
Test #33:
score: 0
Accepted
time: 279ms
memory: 36600kb
input:
256940 648067 248598 702551234623621497
output:
107167397
result:
ok "107167397"
Test #34:
score: 0
Accepted
time: 91ms
memory: 32608kb
input:
112359 956967 160416 704822623170226832
output:
945781095
result:
ok "945781095"
Test #35:
score: 0
Accepted
time: 1055ms
memory: 78944kb
input:
608294 272679 879126 922348606336628938
output:
508826865
result:
ok "508826865"
Test #36:
score: 0
Accepted
time: 457ms
memory: 48144kb
input:
844223 856121 402112 640219260480538711
output:
494733011
result:
ok "494733011"
Test #37:
score: 0
Accepted
time: 103ms
memory: 21080kb
input:
589375 991964 85955 471255438930064341
output:
591777452
result:
ok "591777452"
Test #38:
score: 0
Accepted
time: 564ms
memory: 51452kb
input:
613807 685977 493404 774205724944088968
output:
686401274
result:
ok "686401274"
Test #39:
score: 0
Accepted
time: 60ms
memory: 20432kb
input:
686801 458561 52258 593361261434725536
output:
197205169
result:
ok "197205169"
Extra Test:
score: 0
Extra Test Passed