按照题意算出 ti,j
维护长度是 i-len—-i的标记数组,然后找第一个没有标记的就行啦
#include <cstdio>
#include <iostream>
#define ll long long
using namespace std;
ll mile[210000];
bool ts[110000];
int main()
{
//freopen("a.in","r",stdin);
//freopen("right.out","w",stdout);
ll n,m,x,y;
scanf("%lld%lld%lld%lld",&n,&m,&x,&y);
scanf("%lld%lld",&mile[1],&mile[2]);
ll len=((double)n/2.0);
//printf("%d\n",len);
//ll now=3-len;
//now=max(now,1ll*1);
for(ll i=1;i<=2;i++)
ts[mile[i]]=1;
for(ll i=3;i<=m;i++)
{
ll tmp=(1ll*(x*mile[i-1])%n+1ll*(y*mile[i-2])%n)%n;
while(1)
{
if(!ts[tmp])
{
mile[i]=tmp;
ts[tmp]=1;
printf("%lld ",tmp);
break;
}
else tmp=(tmp+1)%n;
}
if(i>len)
ts[mile[i-len]]=0;
}
return 0;
}