Cod sursa(job #2708090)

Utilizator CiboAndreiAndrei Cibo CiboAndrei Data 18 februarie 2021 12:03:12
Problema Curcubeu Scor 20
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.12 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");

//Daca merge ma duc si ma culc

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

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

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


void init(){
    f >> n >> a >> b >> c;
}

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

void solve(){
    int i;

    for(i = 1; i < n; ++i){
        a = (a*i) % n;
        b = (b*i) % n;
        c = (c*i) % n;

        if(a < b){
            v.push_back({a, b, c});
        } else {
            v.push_back({b, a, c});
        }
    }

    int nrc = 0;

    for(i = n - 2; i >= 0 && nrc < n - 1; --i){
        a = v[i].x;
        b = v[i].y;
        c = v[i].z;

        for(; a <= b; ++a){
            if(sol[a] == 0){
                sol[a] = c;
                ++nrc;
            }
        }
    }
}

int main(){
    init();
    solve();
    print_sol();

    return 0;
}