提交时间:2021-05-16 21:33:48

运行 ID: 19599

#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+=a[i]*t; t*=4; } ha[sum]=1,t/=4; for(int i=k+1;i<=n;++i){ sum/=4; sum+=a[i]*t; ha[sum]=1; } for(int i=0;i<2000000;++i) if(ha[i]==1)ans++; cout<<ans; return 0; }