Pagini recente » Cod sursa (job #2649982) | Cod sursa (job #2106865) | Cod sursa (job #2039467) | Cod sursa (job #2899592) | Cod sursa (job #3236720)
#include <bits/stdc++.h>
std :: ifstream in ("curcubeu.in");
std :: ofstream out ("curcubeu.out");
const int NMAX = 1e6 + 5;
int n;
int a;
int b;
int c;
int v[NMAX];
int jump[NMAX];
std :: stack <std :: pair<std :: pair<int, int>, int>> s;
int main()
{
in >> n >> a >> b >> c;
s.push(std :: make_pair(std :: make_pair(a, b), c));
for(int i = 2; i < n; i ++)
{
a *= i;
b *= i;
c *= i;
a %= n;
b %= n;
c %= n;
s.push(std :: make_pair(std :: make_pair(a, b), c));
}
for(int i = 1; i < n; i ++)
{
jump[i] = i + 1;
}
while(!s.empty())
{
a = s.top().first.first;
b = s.top().first.second;
c = s.top().second;
s.pop();
if(a > b)
{
std :: swap(a, b);
}
int i = a;
while(i <= b)
{
if(!v[i])
{
v[i] = c;
}
i = jump[i];
}
jump[a] = std :: max(jump[a], b);
}
for(int i = 1; i < n; i ++)
{
out << v[i] << '\n';
}
return 0;
}