Pagini recente » Cod sursa (job #120643) | Cod sursa (job #1053558) | Cod sursa (job #2317008) | Cod sursa (job #2224790) | Cod sursa (job #2777686)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
const int nmax = 1e6;
int n, a[nmax + 5], b[nmax + 5], c[nmax + 5], ans[nmax + 5], t[nmax + 5];
vector <pair <int, int> > v;
vector <int> nr;
int main()
{
fin >> n >> a[1] >> b[1] >> c[1];
t[1] = 1;
for (int i = 2; i < n; ++i) {
a[i] = (a[i - 1] * i) % n;
b[i] = (b[i - 1] * i) % n;
c[i] = (c[i - 1] * i) % n;
t[i] = i;
}
for (int i = n - 1; i >= 1; --i) {
int st = a[i], dr = b[i], x = c[i];
if (st > dr) swap(st, dr);
while (st <= dr) {
if (st != t[st]) {
st = t[++st];
continue;
}
ans[st] = x;
t[st] = dr + 1;
if (st + 1 > dr) break;
st = t[++st];
}
}
for (int i = 1; i < n; ++i) fout << ans[i] << '\n';
return 0;
}