QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775699#56. Nim ProductPhysics212303100 ✓924ms3948kbC++17753b2024-11-23 16:30:422024-11-23 16:30:43

Judging History

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

  • [2024-11-23 16:30:43]
  • 评测
  • 测评结果:100
  • 用时:924ms
  • 内存:3948kb
  • [2024-11-23 16:30:42]
  • 提交

answer

#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
static int r[256][256];
unsigned f(unsigned x,unsigned y,int p=16){
  if(x<=1||y<=1)return x*y;
  if(p<8&&r[x][y])return r[x][y];
  unsigned a=x>>p,b=(1u<<p)-1&x,c=y>>p,d=(1u<<p)-1&y;
  unsigned u=f(b,d,p>>1),v=f(f(a,c,p>>1),1u<<p>>1,p>>1);
  unsigned w=((f(a^b,c^d,p>>1)^u)<<p)^v^u;
  if(p<8)r[x][y]=r[y][x]=w;
  return w;
}
unsigned SA,SB,SC;
inline unsigned rng(){
  SA^=SA<<16,SA^=SA>>5,SA^=SA<<1;
  unsigned t=SA;
  return SA=SB,SB=SC,SC^=t^SA;
}
int main(){
  ios::sync_with_stdio(false);
  unsigned t,l=0; cin>>t>>SA>>SB>>SC;
  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: 3816kb

input:

10 274134852 279286565 744539633

output:

2002382043

result:

ok single line: '2002382043'

Test #2:

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

input:

1000 734766235 309378503 610268282

output:

2106551671

result:

ok single line: '2106551671'

Test #3:

score: 25
Accepted
time: 2ms
memory: 3812kb

input:

30000 784936363 827067061 800454511

output:

554318281

result:

ok single line: '554318281'

Test #4:

score: 25
Accepted
time: 924ms
memory: 3832kb

input:

30000000 72129929 485897764 129463885

output:

92762235

result:

ok single line: '92762235'