Pagini recente » Cod sursa (job #57401) | Cod sursa (job #3265948) | Cod sursa (job #142737) | Cod sursa (job #989033) | Cod sursa (job #1495222)
# include <cstdio>
# include <algorithm>
# define MAX (1000000 + 5)
using namespace std;
int N, x, y, z, i, j;
int a[MAX], b[MAX], c[MAX], d[MAX], aux[MAX];
int next(int x) {
if (!d[x]) return x;
else{
d[x] = next(d[x]);
return d[x];
}
}
int main ()
{
freopen("curcubeu.in","r",stdin);
freopen("curcubeu.out","w",stdout);
scanf("%d", &N);
scanf("%d %d %d", &x, &y, &z);
a[1] = x;
b[1] = y;
c[1] = z;
for (i = 2; i <= N; i++){
a[i] = 1LL* (1LL*a[i-1] * i) % N;
b[i] = 1LL* (1LL*b[i-1] * i) % N;
c[i] = 1LL* (1LL*c[i-1] * i) % N;
}
for (i = N; i >= 1; i--){
long long Min = min (a[i], b[i]);
long long Max = max (a[i], b[i]);
for (j = next(Min); j <= Max; j = next(j + 1)){
aux[j] = c[i];
d[j] = Max + 1;
}
}
for (i = 1; i <= N - 1; ++i)
printf("%d\n", aux[i]);
return 0;}