Mai intai trebuie sa te autentifici.
Cod sursa(job #3360998)
| Utilizator | Data | 18 iulie 2026 13:46:43 | |
|---|---|---|---|
| Problema | Curcubeu | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.68 kb |
#include <fstream>
#include <set>
using namespace std;
ifstream cin("curcubeu.in");
ofstream cout("curcubeu.out");
int X[1000005];
int A[1000005];
int B[1000005];
int C[1000005];
set <int> V;
int main() {
int n, a, b, c;
cin>>n>>a>>b>>c;
for (int i=1; i<=n-1; i++) {
A[i]=a;
B[i]=b;
C[i]=c;
a=(a*i)%n;
b=(b*i)%n;
c=(c*i)%n;
V.insert(i);
}
for (int i=n-1; i>=1; i--) {
for (auto it=V.upper_bound(min(A[i], B[i])); it!=V.lower_bound(max(A[i], B[i])); it++) {
X[*it]=C[i];
V.erase(*it);
}
}
for (int i=1; i<=n-1; i++) cout<<X[i]<<"\n";
}
