Pagini recente » Cod sursa (job #2240630) | Cod sursa (job #246583) | Cod sursa (job #2125288) | Cod sursa (job #262087) | Cod sursa (job #2225820)
#include <cstdio>
#include <algorithm>
using namespace std;
const int NMAX = 1000005;
const int DIM = (1 << 17);
int n, bp;
int a[1 + NMAX], b[1 + NMAX], c[1 + NMAX], poz[1 + NMAX], v[1 + NMAX];
char buff[DIM];
void write_char(char ch) {
if(bp == DIM) {
fwrite(buff, 1, DIM, stdout);
bp = 0;
}
buff[bp++] = ch;
}
void write(int n) {
if(n <= 9)
write_char(n + '0');
else {
write(n / 10);
write_char(n % 10 + '0');
}
}
void write_all() {
fwrite(buff, 1, DIM, stdout);
}
int main() {
freopen("curcubeu.in", "r", stdin);
freopen("curcubeu.out", "w", stdout);
scanf("%d %d %d %d", &n, &a[1], &b[1], &c[1]);
poz[1] = 1;
for(int i = 2; i < n; i++) {
a[i] = 1LL * a[i - 1] * i % n;
b[i] = 1LL * b[i - 1] * i % n;
c[i] = 1LL * c[i - 1] * i % n;
poz[i] = i;
}
for(int i = n - 1; i >= 1; i--) {
int j = min(a[i], b[i]), lim = max(a[i], b[i]);
while(j <= lim) {
if(v[j])
j = poz[j];
else {
v[j] = c[i];
poz[j] = lim + 1;
j++;
}
}
}
for(int i = 1; i < n; i++) {
write(v[i]);
write_char('\n');
}
write_all();
return 0;
}