Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <cstdio>
- #include <iostream>
- #include <cmath>
- unsigned int cur = 0;
- unsigned int nextRand24(int a, int b) {
- cur = cur * a + b;
- return cur >> 8;
- }
- unsigned int nextRand32(int a1, int b1) {
- unsigned int a = nextRand24(a1, b1), b = nextRand24(a1, b1);
- return (a << 8) ^ b;
- }
- int cmp(const void *x1, const void *x2) {
- long long res = (*(long long *) x1 - *(long long *) x2);
- res = res % INTMAX_MAX;
- return (int) res;
- }
- long long gcd(long long a, long long b) {
- long long c;
- while (b != 0) {
- c = a % b;
- a = b;
- b = c;
- }
- return (abs(a));
- }
- int main() {
- long long sum = 0;
- int n, a, b;
- std::cin >> n >> a >> b;
- long long x[n];
- for (int i = 0; i < n; i++) {
- x[i] = nextRand32(a, b);
- }
- for (int i = 0; i < n; i++) {
- sum += x[i];
- }
- long long g = (gcd(sum, n));
- sum = sum / g;
- n = n / g;
- std::cout << sum << "/" << n;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement