Pagini recente » Cod sursa (job #1307754) | Cod sursa (job #2251247) | Cod sursa (job #2068913) | Istoria paginii runda/smenuri | Cod sursa (job #2057737)
#include <fstream>
#include <cstring>
using namespace std;
#pragma GCC optimize "O3"
ifstream fi("radixsort.in");
ofstream fo("radixsort.out");
/*
#define BUFMAX 11000000
int bufcnt = BUFMAX - 1; char buf[BUFMAX];
inline void write(int x) {
buf[bufcnt--] = ' ';
do buf[bufcnt--] = x % 10 + '0', x /= 10; while (x);
}
inline void flush() { fo.write(buf + bufcnt + 1, BUFMAX - bufcnt - 2); }
*/
const int BITS = 8;
const int MASK = (1 << BITS) - 1;
#define MAX 10000000
int v[MAX];
int main() {
int n, b, c; unsigned long long a; fi >> n >> a >> b >> c;
v[0] = b; a %= c, b %= c;
for (int i = 1; i < n; i++) {
unsigned long long t = a * v[i - 1] + b;
int thi = t >> 32, tlo = t; int aux;
asm("divl %4" : "=a"(aux), "=d"(v[i]) : "0"(tlo), "1"(thi), "r"(c));
}
//for (int i = n - 1 - (n - 1) % 10; i >= 0; i -= 10) write(v[i]); flush();
for (int i = 0; i < n; i += 10) fo << v[i] << ' ';
}