Pagini recente » Cod sursa (job #885617) | Cod sursa (job #895999) | Cod sursa (job #2611604) | Cod sursa (job #2819457) | Cod sursa (job #2104393)
#include <stdio.h>
#define Nmax 1000001
struct str{
int A, B, C;
}v[Nmax];
int rez[Nmax], next[Nmax];
inline void swap(int *a, int *b){
int aux;
aux=*a;
*a=*b;
*b=aux;
}
int main(){
freopen("curcubeu.in", "r", stdin);
freopen("curcubeu.out", "w", stdout);
int n, i, j;
scanf("%d %d %d %d", &n, &v[1].A, &v[1].B, &v[1].C);
if(v[1].A>v[1].B)
swap(&(v[1].A), &(v[1].B));
for(i=2; i<=n-1; i++){
v[i].A=(1LL*v[i-1].A*i)%n;
v[i].B=(1LL*v[i-1].B*i)%n;
v[i].C=(1LL*v[i-1].C*i)%n;
if(v[i].A>v[i].B)
swap(&v[i].A, &v[i].B);
}
int nxt=0;
for(i=n-1; i>=1; i--)
for(j=v[i].A; j<=v[i].B; j++)
if(rez[j]==0){
rez[j]=v[i].C;
}
// next[j]=v[i].B;
// } else{
// j=next[j];
// }
for(i=1; i<n; i++)
printf("%d\n", rez[i]);
return 0;
}