SHARE
TWEET

Untitled

a guest Oct 19th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #include <algorithm>
  3. #include <cstdio>
  4. #include <iostream>
  5. #include <cmath>
  6.  
  7. unsigned int cur = 0;
  8.  
  9. unsigned int nextRand24(int a, int b) {
  10.     cur = cur * a + b;
  11.     return cur >> 8;
  12. }
  13.  
  14. unsigned int nextRand32(int a1, int b1) {
  15.     unsigned int a = nextRand24(a1, b1), b = nextRand24(a1, b1);
  16.     return (a << 8) ^ b;
  17. }
  18.  
  19. int cmp(const void *x1, const void *x2) {
  20.     long long res = (*(long long *) x1 - *(long long *) x2);
  21.     res = res % INTMAX_MAX;
  22.     return (int) res;
  23. }
  24.  
  25. long long gcd(long long a, long long b) {
  26.     long long c;
  27.     while (b != 0) {
  28.         c = a % b;
  29.         a = b;
  30.         b = c;
  31.     }
  32.     return (abs(a));
  33. }
  34.  
  35. int main() {
  36.     long long sum = 0;
  37.     int n, a, b;
  38.     std::cin >> n >> a >> b;
  39.     long long x[n];
  40.     for (int i = 0; i < n; i++) {
  41.         x[i] = nextRand32(a, b);
  42.     }
  43.  
  44.     for (int i = 0; i < n; i++) {
  45.         sum += x[i];
  46.     }
  47.     long long g = (gcd(sum, n));
  48.     sum = sum / g;
  49.     n = n / g;
  50.     std::cout << sum << "/" << n;
  51.     return 0;
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top