提交时间:2021-05-15 17:13:51

运行 ID: 19386

#include<bits/stdc++.h> using namespace std; int a[100010],r[100010],ha[2000000]; int n,k,t=1,ans,sum; void init() { cin>>n>>k>>r[1]; for(int i=1;i<=n;++i){ a[i]=r[i]%4; r[i+1]=(r[i]*6807+2831)%201701; } } int main() { init(); for(int i=1;i<=k;++i){ sum=sum+a[i]*t; t=t*4; } ha[sum]=1;t=t/4; for(int i=k+1;i<=n;++i){ sum=sum/4; sum=sum+a[i]*t; ha[sum]=1; } for(int i=0;i<2000000;++i) if(ha[i]==1)ans++; cout<<ans; return 0; }