提交时间:2021-05-22 12:55:45

运行 ID: 19744

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