Cod sursa(job #2057735)

Utilizator neth------ neth Data 4 noiembrie 2017 18:05:04
Problema Radix Sort Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.63 kb
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize "O3"
ifstream fi("radixsort.in");
ofstream fo("radixsort.out");

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] << ' ';
}