Pagini recente » Cod sursa (job #152245) | Cod sursa (job #2486380) | Cod sursa (job #548484) | Cod sursa (job #364435) | Cod sursa (job #2603218)
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
ifstream fin("curcubeu.in");
ofstream fout("curcubeu.out");
const int nmax=1000005;
int n,a0,b0,c0,af,bf,cf;
int cells[nmax],range[nmax];
struct r
{
int x,y,colour;
}v[nmax];
void read()
{
fin>>n>>a0>>b0>>c0;
v[1]={a0,b0,c0};
for(int i=2;i<n;i++)
{
af=(a0*i)%n;
bf=(b0*i)%n;
cf=(c0*i)%n;
v[i]={af,bf,cf};
a0=af,b0=bf,c0=cf;
}
}
void solve()
{
memset(cells,-1,sizeof(cells));
for(int i=n-1;i>=1;i--)
{
range[v[i].x]=v[i].y;
//fout<<v[i].x<<" "<<v[i].y<<"\n";
for(int j=v[i].x;j<=v[i].y;j++)
if(cells[j]==-1)
cells[j]=v[i].colour;
else
j=range[j]+1;
}
for(int i=1;i<n;i++)
fout<<cells[i]<<"\n";
}
int main()
{
read();
solve();
return 0;
}