QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775636#56. Nim ProductPhysics21230375 5ms4192kbC++17692b2024-11-23 16:21:372024-11-23 16:21:38

Judging History

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

  • [2024-11-23 16:21:38]
  • 评测
  • 测评结果:75
  • 用时:5ms
  • 内存:4192kb
  • [2024-11-23 16:21:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
static ull r[256][256];
ull f(ull x,ull y,int p=32){
  if(x<=1||y<=1)return x*y;
  if(p<8&&r[x][y])return r[x][y];
  ull a=x>>p,b=(1ull<<p)-1&x,c=y>>p,d=(1ull<<p)-1&y;
  ull u=f(b,d,p>>1),v=f(f(a,c,p>>1),1ull<<p>>1,p>>1);
  ull w=((f(a^b,c^d,p>>1)^u)<<p)^v^u;
  if(p<8)r[x][y]=r[y][x]=w;
  return w;
}
main(){
  ios::sync_with_stdio(false);
  unsigned t,SA,SB,SC,l=0; cin>>t>>SA>>SB>>SC;
  auto rng=[&](){
    SA^=SA<<16,SA^=SA>>5,SA^=SA<<1;
    unsigned t=SA;
    return SA=SB,SB=SC,SC^=t^SA;
  };
  while(t--){
    unsigned x=rng()+l,y=rng(); l=f(x,y);
  }
  cout<<l<<endl;
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Pretests


Final Tests

Test #1:

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

input:

10 274134852 279286565 744539633

output:

2002382043

result:

ok single line: '2002382043'

Test #2:

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

input:

1000 734766235 309378503 610268282

output:

2106551671

result:

ok single line: '2106551671'

Test #3:

score: 25
Accepted
time: 5ms
memory: 4120kb

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: