Pagini recente » Cod sursa (job #1274633) | Cod sursa (job #1317154) | Cod sursa (job #19637) | Cod sursa (job #2089624) | Cod sursa (job #3204829)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
int n,m,i,j,a,b,c,st,dr,father[100005],sol[1000005];
struct s
{
int c,b,a;
}color[1000005];
int main()
{
fin>>n>>a>>b>>c;
father[1] = 1;
color[1].a=a , color[1].b=b , color[1].c = c;
for(i=2;i<n;i++)
{
a = color[i].a = a*i%n;
b = color[i].b = b*i%n;
c = color[i].c = c*i%n;
father[i]=i;
}
father[n] = 0;
for(i=n-1;i>=1;i--)
{
st = min(color[i].a, color[i].b);
dr = max(color[i].a, color[i].b);
for(j = st;j<=dr && j<n; j++)
{
if(!sol[j])
{
sol[j] = color[i].c;
father[j] = dr+1; ///!
j++;
}
else
j = father[j];
}
}
for(i=1; i<n;i++)
fout<<sol[i]<<'\n';
return 0;
}