Pagini recente » Cod sursa (job #2800327) | Cod sursa (job #1367487) | Cod sursa (job #2183244) | Cod sursa (job #1609416) | Cod sursa (job #3193014)
#include <fstream>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
const int DIM = 1000010;
int n;
int a[DIM], b[DIM], c[DIM];
int nextPos[DIM], color[DIM];
int main() {
fin >> n >> a[1] >> b[1] >> c[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;
}
for (int i = 1; i < n; i++)
nextPos[i] = i + 1;
for (int i = n - 1; i >= 1; i--) {
if (a[i] > b[i])
swap(a[i], b[i]);
for (int j = a[i]; j <= b[i]; j++) {
if (color[j] != 0) {
j = nextPos[j] - 1;
} else {
color[j] = c[i];
nextPos[j] = b[i] + 1;
}
}
}
for (int i = 1; i < n; i++)
fout << color[i] << '\n';
return 0;
}