Pagini recente » Cod sursa (job #1576947) | Cod sursa (job #2083373) | Cod sursa (job #738248) | Cod sursa (job #2371866) | Cod sursa (job #2708031)
#include <bits/stdc++.h>
using namespace std;
ifstream f("curcubeu.in");
ofstream g("curcubeu.out");
const int Max = 1e6 + 1;
void nos()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
#define color first
#define time second
int n,a,b,c;
pair < int, int > tree[4*Max];
int rev[Max];
int timp;
int left_limit;
int right_limit;
int color;
void color_layer(int where, int left, int right)
{
if(left_limit <= left and right <= right_limit)
{
tree[where].color = color;
tree[where].time = timp;
return;
}
int mid = (left + right) / 2;
if(left_limit <= mid)
color_layer(2*where,left,mid);
if(mid + 1 <= right_limit)
color_layer(2*where+1,mid+1,right);
}
void get_rev(int where, int left, int right)
{
if(left == right)
{
rev[left] = where;
return;
}
int mid = (left + right) / 2;
get_rev(2*where,left,mid);
get_rev(2*where+1,mid+1,right);
}
void read()
{
f>>n>>a>>b>>c;
}
pair < int, int > ans;
void ask(int where)
{
if(tree[where].time > ans.time)
ans = tree[where];
if(where!=1)
ask(where/2);
}
void solve()
{
get_rev(1,1,n-1);
int i;
timp = 1;
left_limit = min(a,b);
right_limit = max(a,b);
color = c;
color_layer(1,1,n-1);
for(i=2; i<n; i++)
{
timp = i;
a = (1LL*a * i) % n;
b = (1LL*b * i) % n;
c = (1LL*c * i) % n;
left_limit = min(a,b);
right_limit = max(a,b);
color = c;
color_layer(1,1,n-1);
// cout<<a<<' '<<b<<' '<<c<<'\n';
}
// for(i=1; i<n; i++)
// {
// ans.color = 0;
// ans.time = 0;
// ask(rev[i]);
// g<<ans.color<<'\n';
// }
}
void restart()
{
}
int32_t main()
{
nos();
read();
solve();
restart();
return 0;
}