Cod sursa(job #2708155)

Utilizator CiboAndreiAndrei Cibo CiboAndrei Data 18 februarie 2021 12:58:35
Problema Curcubeu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.88 kb
#include <bits/stdc++.h>

using namespace std;

//#define f cin
//#define g cout
//ifstream f("data.in");
//ofstream g("data.out");
ifstream f("curcubeu.in");
ofstream g("curcubeu.out");

const int dim = 1e6 + 2;
const short int mod = 1e9 + 7;

long long n, a[dim], b[dim], c[dim];
int sol[dim];

struct str{
    long long x, y, z;
};
vector <str> v;

int inv[dim];

int main(){
    f >> n >> a[1] >> b[1] >> c[1];

    int i, j;

    for(i = 2; i < n; ++i){
        a[i] = (a[i-1]*i) % n;
        b[i] = (b[i-1]*i) % n;
        c[i] = (c[i-1]*i) % n;
    }

    for(i = n - 1; i >= 0; --i){
        for(j = a[i]; j <= b[i]; ++j){
            if(inv[j] == 0){
                sol[j] = c[i];
                inv[j] = b[i];
            } else j = inv[j];
        }
    }

    for(int i = 1; i < n; ++i)
        g << sol[i] << '\n';

    return 0;
}