Pagini recente » Cod sursa (job #1967822) | Cod sursa (job #2370356) | Cod sursa (job #2082877) | Cod sursa (job #2836402) | Cod sursa (job #567228)
Cod sursa(job #567228)
#include <cstdio>
#define infile "curcubeu.in"
#define outfile "curcubeu.out"
#define MaxN 1000002
int c[MaxN],next[MaxN];
int A,B,C,N;
void read()
{
scanf("%d%d%d%d",&N,&A,&B,&C);
}
void swap(int &A,int &B)
{
int aux;
if(A>B)
{
aux=A; A=B; B=aux;
}
}
void sol(int nr,int A,int B,int C)
{
int i;
if(nr==N)
{
swap(A,B);
for(i=A;i<=B;i++)
c[i]=C, next[i]=B;
return;
}
sol(nr+1,(A*nr)%N,(B*nr)%N,(C*nr)%N);
swap(A,B);
i=A;
while(i<=B)
{
if(next[i]==i)
{
if(!c[i])
c[i]=C;
next[i]=B;
i++;
}
else
i=next[i];
}
}
void solve()
{
int i;
for(i=1;i<N;i++) next[i]=i;
sol(2,A,B,C);
}
void write()
{
int i;
for(i=1;i<N;i++)
printf("%d\n",c[i]);
}
int main()
{
freopen(infile,"r",stdin);
freopen(outfile,"w",stdout);
read();
solve();
write();
fclose(stdin);
fclose(stdout);
return 0;
}