Pagini recente » Cod sursa (job #2481468) | Cod sursa (job #3228544) | Cod sursa (job #1040882) | Cod sursa (job #2949953) | Cod sursa (job #2839748)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF=1e9+7;
const ll INFF=1e18+7;
#define nl '\n'
void __print(int x) { cout << x; }
void __print(long x) { cout << x; }
void __print(long long x) { cout << x; }
void __print(unsigned x) { cout << x; }
void __print(unsigned long x) { cout << x; }
void __print(unsigned long long x) { cout << x; }
void __print(float x) { cout << x; }
void __print(double x) { cout << x; }
void __print(long double x) { cout << x; }
void __print(char x) { cout << '\'' << x << '\''; }
void __print(const char* x) { cout << '\"' << x << '\"'; }
void __print(const string& x) { cout << '\"' << x << '\"'; }
void __print(bool x) { cout << (x ? "true" : "false"); }
template<typename T, typename V>
void __print(const pair<T, V>& x) { cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}'; }
template<typename T>
void __print(const T& x) { int f = 0; cout << '{'; for (auto& i : x) cout << (f++ ? "," : ""), __print(i); cout << "}"; }
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) { __print(t); if (sizeof...(v)) cout << ", "; _print(v...); }
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
vector<tuple<ll,ll,ll>> v(1'000'001);
vector<ll> ans(1'000'001), colored(1'000'001);
ll available(int j){
// if(!colored[j]) return j;
int next=colored[j];
while(next!=colored[next]){
next=colored[next];
}
ll aux=next;
next=colored[j];
while(next!=colored[next]){
int a=next;
next=colored[next];
colored[a]=aux;
}
return aux;
}
void solve()
{
ll n,a,b,c;
cin>>n>>a>>b>>c;
v[1]=tie(a,b,c);
colored[1]=1;
for(int i=2; i<n; i++){
a=(a*i)%n;
b=(b*i)%n;
c=(c*i)%n;
v[i]=tie(min(a,b),max(a,b),c);
colored[i]=i;
}
colored[n]=n;
for(int i=n-1; i>0; i--){
ll a,b,c;
tie(a,b,c)=v[i];
for(int j=available(a); j<=b;){
ans[j]=c;
ll next=available(j+1);
colored[j]=next;
// colored[j]=next;
j=next;
// debug(j,a,b,c);
// j=available(j+1);
// debug(j,available(j+1));
// j=aa;
// j--;
// debug(j);
}
}
for(int i=1; i<n; i++){
cout<<ans[i]<<nl;
}
}
int main()
{
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
freopen("curcubeu.in", "r", stdin);
freopen("curcubeu.out", "w", stdout);
// #endif
ios::sync_with_stdio(0);
cin.tie(0);
int t=1;
// int t;
// cin >> t;
for(int tt=1; tt<=t; tt++){
// cout<<"#Case "<<t<<nl;
solve();
}
return 0;
}