QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834580 | #9878. A xor B plus C | ucup-team1004 | RE | 3ms | 4164kb | C++14 | 899b | 2024-12-27 20:39:11 | 2024-12-27 20:39:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 i128;
const int K=20;
vector<i128> v1,v2;
ll n;
i128 ans;
int a,b,c,t[3];
int main()
{
scanf("%d%d%d%lld",&a,&b,&c,&n),n-=3;
if(n<0) return printf("%d\n",n==-2?a:b),0;
ll m=3<<(K-1);
for(int i=0;i<m;i++)
{
int res=(a^b)+c;
if(res>=(1<<K)&&i<=n) v1.push_back(i),res-=(1<<K);
a=b,b=res;
if(n%m==i) ans=res;
}
for(int j=K;v1.size();j++)
{
for(auto x:v1) v2.push_back(x);
for(auto x:v1) if(x<=n-m) v2.push_back(x+m);
v1.clear(),m<<=1;
ll k=n%m;
for(int i=0;i<3;i++) t[i]=0;
for(auto x:v2)
{
if(x>k) ans|=((i128)t[k%3])<<j,k=m;
int res=t[x%3];
if(res==1) v1.push_back(x);
t[x%3]^=1,t[(x+1)%3]^=1;
}
if(k<m) ans|=((i128)t[k%3])<<j;
while(v1.size()&&v1.back()>n) v1.pop_back();
v2.clear();
}
printf("%d\n",(int)(ans%998244353));
}
详细
Test #1:
score: 100
Accepted
time: 3ms
memory: 3792kb
input:
1 2 3 4
output:
7
result:
ok "7"
Test #2:
score: 0
Accepted
time: 3ms
memory: 4164kb
input:
123 456 789 123456789
output:
567982455
result:
ok "567982455"
Test #3:
score: 0
Accepted
time: 3ms
memory: 4088kb
input:
0 0 0 1000000000000000000
output:
0
result:
ok "0"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3788kb
input:
628 314 157 1
output:
628
result:
ok "628"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
167 924 167 2
output:
924
result:
ok "924"
Test #6:
score: 0
Accepted
time: 3ms
memory: 4092kb
input:
1048575 1048575 1048575 1000000000000000000
output:
1048575
result:
ok "1048575"
Test #7:
score: -100
Runtime Error
input:
287144 758614 992207 1000000000000000000