Cod sursa(job #2708141)

Utilizator AACthAirinei Andrei Cristian AACth Data 18 februarie 2021 12:54:37
Problema Curcubeu Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.12 kb
#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
#define int long long
int n;
int a[Max],b[Max],c[Max];
int sol[Max];
int A,B,C;
void read()
{
    f>>n>>A>>B>>C;
    a[1] = min(A,B);
    b[1] = max(A,B);
    c[1] = C;
}
int skip[Max];

void solve()
{
    int i;
    for(i=2; i<n; ++i)
    {
        A = (1LL*A * i) % n;
        B = (1LL*B * i) % n;
        C = (1LL*C * i) % n;
        a[i] = min(A,B);
        b[i] = max(A,B);
        c[i] = C;
    }
    for(i=n-1 ; i >= 1; --i)
    {

        int j;
        for(j=a[i]; j<=b[i]; ++j)
        {
            if(skip[j] == 0)
            {
                sol[j] = c[i];
                skip[j] = b[i];
            }
            else
                j = skip[j];
        }
    }
    for(i=1; i<n; ++i)
        g<<sol[i]<<'\n';
}
void restart()
{

}

int32_t main()
{
    nos();

    read();
    solve();
    restart();

    return 0;
}