Cod sursa(job #3278921)

Utilizator SkibidiCezarCezar Bolba SkibidiCezar Data 21 februarie 2025 13:04:48
Problema Curcubeu Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.81 kb
#include <bits/stdc++.h>

using namespace std;
ifstream fin ("curcubeu.in");
ofstream fout ("curcubeu.out");
int n;
struct inter{
    int st;
    int dr;
    int c;
};
inter a[1000000];
int col[1000000];
int poz[1000000];

int main()
{
    fin >> n >> a[1].st >> a[1].dr >> a[1].c;
    for(int i = 2; i < n; i++){
        a[i].st = (a[i-1].st * i) % n;
        a[i].dr = (a[i-1].dr * i) % n;
        a[i].c = (a[i-1].c * i) % n;
    }
    for(int i = n - 1; i > 0; i--){
        for(int j = a[i].st; j <= a[i].dr; j++){
            if(poz[j] > 0){
                j = poz[j];
            }
            else{
                poz[j] = a[i].dr;
                col[j] = a[i].c;
            }
        }
    }
    for(int i = 1; i < n; i++){
        fout << col[i] << "\n";
    }
    return 0;
}