QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#667455#56. Nim Productxx_mmc75 4ms4364kbC++14974b2024-10-22 23:11:122024-10-22 23:11:20

Judging History

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

  • [2024-10-22 23:11:20]
  • 评测
  • 测评结果:75
  • 用时:4ms
  • 内存:4364kb
  • [2024-10-22 23:11:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define uint unsigned int
#define ll long long
#define mod 998244353
#define N 256
uint SA, SB, SC;
uint rng() {
    SA ^= SA << 16;
    SA ^= SA >> 5;
    SA ^= SA << 1;
    uint t = SA;
    SA = SB;
    SB = SC;
    SC ^= t ^ SA;
    return SC;
}
uint lastans;
ll rem[N][N],r8[1<<8];
uint nimP(uint x,uint y,int k=16){
	if(x<=1||y<=1)return x*y;
	if(k<8&&rem[x][y]>=0)return rem[x][y];
	uint a=x>>k,b=y>>k,c=x&((1ull<<k)-1),d=y&((1ull<<k)-1);
	uint ab=nimP(1ull<<k>>1,nimP(a,b,k>>1),k>>1);
	uint cd=nimP(c,d,k>>1);
	uint ans=((nimP(a^c,b^d,k>>1)^cd)<<k)^ab^cd;
	if(k<8)rem[x][y]=ans;
	return ans;
}
int main(){
	memset(rem,-1,sizeof rem);
	memset(r8,-1,sizeof r8);
	int T;
	scanf("%d%u%u%u",&T,&SA,&SB,&SC);
	while(T--){
		uint x = rng() + (unsigned int)lastans;
		uint y = rng();
		lastans = nimP(x, y);
	}
	printf("%u\n",lastans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

score: 25
Accepted
time: 1ms
memory: 4264kb

input:

10 274134852 279286565 744539633

output:

2002382043

result:

ok single line: '2002382043'

Test #2:

score: 25
Accepted
time: 0ms
memory: 4364kb

input:

1000 734766235 309378503 610268282

output:

2106551671

result:

ok single line: '2106551671'

Test #3:

score: 25
Accepted
time: 4ms
memory: 4316kb

input:

30000 784936363 827067061 800454511

output:

554318281

result:

ok single line: '554318281'

Test #4:

score: 0
Time Limit Exceeded

input:

30000000 72129929 485897764 129463885

output:


result: