Cod sursa(job #2651085)

Utilizator Moise_AndreiMoise Andrei Moise_Andrei Data 21 septembrie 2020 16:00:53
Problema Curcubeu Scor 50
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.08 kb
#include <bits/stdc++.h>
#define int long long
using namespace std;
ifstream in("curcubeu.in");
ofstream out("curcubeu.out");
int a[1000005];
int b[1000005];
int c[1000005];
int v[1000005];
int rez[1000005];
int32_t main()
{
    int n;
    in >> n >> a[1] >> b[1] >> c[1];
    if(a[1] > b[1])
        swap(a[1], b[1]);
    for(int i = 2; i <= n; i ++)
    {
        a[i] = (1LL * a[i - 1] * i);
        if(a[i] >= n)
            a[i] = a[i] % n;
        b[i] = (1LL * b[i - 1] * i);
        if(b[i] >= n)
            b[i] = b[i] % n;
        c[i] = (1LL * c[i - 1] * i);
        if(c[i] >= n)
            c[i] = c[i] % n;
        if(a[i] > b[i])
            swap(a[i], b[i]);
    }
    for(int i = n - 1; i >= 1; i --)
    {
        for(int j = a[i]; j <= b[i]; j += 0)
        {
            if(rez[j] == 0)
            {
                rez[j] = c[i];
                v[j] = b[i] + 1;
                j ++;
            }
            else
                j = v[j];
        }
    }
    for(int i = 1; i < n; i ++)
        out << rez[i] << '\n';
    return 0;
}