Pagini recente » Cod sursa (job #44950) | Cod sursa (job #2625668) | Cod sursa (job #218642) | Cod sursa (job #762317) | Cod sursa (job #1951162)
#include<fstream>
#define DIM 1000005
using namespace std;
int n, i, j;
int a[DIM], b[DIM], c[DIM], nxt[DIM], sol[DIM];
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int main(){
fin>> n >> a[1] >> b[1] >> c[1];
for(i = 2; i < n; i++){
a[i] = (a[i - 1] * 1LL * i) % n;
b[i] = (b[i - 1] * 1LL * i) % n;
c[i] = (c[i - 1] * 1LL * i) % n;
}
for(i = n - 1; i >= 1; i--){
if(a[i] > b[i]){
swap(a[i], b[i]);
}
j = a[i];
while(j <= b[i]){
if(sol[j] != 0){
j = nxt[j];
}
else{
sol[j] = c[i];
nxt[j] = b[i] + 1;
j++;
}
}
}
for(i = 1; i < n; i++){
fout<< sol[i] <<"\n";
}
return 0;
}