Pagini recente » Cod sursa (job #255103) | Cod sursa (job #1181077) | Cod sursa (job #2061127) | Cod sursa (job #479387) | Cod sursa (job #3266628)
#include<fstream>
#pragma GCC optimize("O3")
std::ifstream fin("curcubeu.in");
std::ofstream fout("curcubeu.out");
const int NMAX=1000005;
int n, a, b, c;
int t[NMAX], colors[NMAX];
struct steps{
int a, b, c;
}v[NMAX];
void read()
{
fin>>n>>a>>b>>c;
const int mod=n;
v[1]={a, b, c};
for(int i=2; i<n; ++i)
{
int A=(1LL*v[i-1].a*i)%mod;
int B=(1LL*v[i-1].b*i)%mod;
int C=(1LL*v[i-1].c*i)%mod;
v[i]={A, B, C};
}
}
inline int root(int x)
{
if(!t[x])
return x;
t[x]=root(t[x]);
return t[x];
}
void solve()
{
for(int step=n-1; step; --step)
{
int A=v[step].a, B=v[step].b, C=v[step].c;
if(A>B)
std::swap(A, B);
for(int pos=root(A); pos<=B;)
{
t[pos]=B+1;
colors[pos]=C;
pos=root(pos+1);
}
}
for(int i=1; i<=n-1; ++i)
fout<<colors[i]<<'\n';
}
int main()
{
read();
solve();
return 0;
}