Cod sursa(job #2646161)

Utilizator saeed_odakSaeed Odak saeed_odak Data 31 august 2020 10:01:01
Problema Radix Sort Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.46 kb
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'

const int N = 1e6 + 6;

int main() {
	// ios::sync_with_stdio(0);
	// cin.tie(0); cout.tie(0);
	freopen("radixsort.in", "r", stdin);
	freopen("radixsort.out", "w", stdout);

	long long n, A, B, C;
	cin >> n >> A >> B >> C;
	int a[n]; a[0] = B;
	for(int i=1; i<n; i++) a[i] = (1LL * A * a[i-1] + B) % C;
	random_shuffle(a, a+n);
	sort(a, a+n);
	for(int i=0; i<n; i+=10) cout << a[i] << " ";

	return 0;
}