Cod sursa(job #2575382)
Utilizator | Nicula Andrei Bogdan niculaandrei | Data | 6 martie 2020 13:11:10 |
---|---|---|---|
Problema | Radix Sort | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.64 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("radixsort.in");
ofstream fout("radixsort.out");
int N, A, B, C, x, target = 1, cnt;
unordered_map < int, int > freq;
set < int > S;
int main()
{
fin >> N >> A >> B >> C;
for (int i = 1; i <= N; i++)
{
if (i == 1)
x = B;
else
x = (A * x + B) % C;
if (freq[x]++ == 0)
S.insert(x);
}
for (auto it: S)
{
N = freq[it];
while (cnt + N >= target)
{
fout << it << " ";
target += 10;
}
cnt += N;
}
return 0;
}