Pagini recente » Cod sursa (job #3122430) | Cod sursa (job #3231506) | Cod sursa (job #1467945) | Cod sursa (job #3039485) | Cod sursa (job #2500947)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("curcubeu.in");
ofstream g ("curcubeu.out");
long long a[1000100], b[1000100], c[1000100],jump[1000100],v[1000100], n;
int main()
{
f>>n>>a[1]>>b[1]>>c[1];
jump[1]=2;
if(a[1]>b[1]) swap(a[1], b[1]);
for(int i=2;i<n;++i)
{
a[i]=(a[i-1]%n*i%n)%n;
b[i]=(b[i-1]%n*i%n)%n;
c[i]=(c[i-1]%n*i%n)%n;
if(a[i]>b[i])
swap(a[i], b[i]);
jump[i]=i+1;
}
long long aux;
for(int i=n-1;i>0;--i)
{
for(int j=a[i];j<=b[i]; aux=jump[j], jump[j]=b[i]+1, j=aux)
{
if(v[j]==0)
v[j]=c[i];
}
}
for(int i=1;i<n;++i)
g<<v[i]<<"\n";
return 0;
}