Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cstdio>
  3. #include <iostream>
  4. #include <cmath>
  5.  
  6. unsigned int cur = 0;
  7.  
  8. unsigned int nextRand24(int a, int b) {
  9. cur = cur * a + b;
  10. return cur >> 8;
  11. }
  12.  
  13. unsigned int nextRand32(int a1, int b1) {
  14. unsigned int a = nextRand24(a1, b1), b = nextRand24(a1, b1);
  15. return (a << 8) ^ b;
  16. }
  17.  
  18. int cmp(const void *x1, const void *x2) {
  19. long long res = (*(long long *) x1 - *(long long *) x2);
  20. res = res % INTMAX_MAX;
  21. return (int) res;
  22. }
  23.  
  24. long long gcd(long long a, long long b) {
  25. long long c;
  26. while (a != b) {
  27. if (a > b) {
  28. c = a;
  29. a = b;
  30. b = c;
  31. }
  32. b = b - a;
  33. }
  34. return a;
  35. }
  36.  
  37. int main() {
  38. long long sum = 0;
  39. int n, a, b;
  40. std::cin >> n >> a >> b;
  41. long long x[n];
  42. for (int i = 0; i < n; i++) {
  43. x[i] = nextRand32(a, b);
  44. }
  45.  
  46. for (int i = 0; i < n; i++) {
  47. sum += x[i];
  48. }
  49. long long g = (gcd(sum, n));
  50.  
  51. sum = sum / g;
  52. n = n / g;
  53. std::cout << sum << "/" << n;
  54. return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement