Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <algorithm>
  2. #include <cstdio>
  3. #include <iostream>
  4. using namespace std;
  5. unsigned int cur = 0;
  6. unsigned int nextRand24(int a, int b) {
  7. cur = cur * a + b;
  8. return cur >> 8;
  9. }
  10. unsigned int nextRand32(int x, int y) {
  11. unsigned int a = nextRand24(x, y);
  12. unsigned int b = nextRand24(x, y);
  13. return ((a << 8)^b);
  14. }
  15. int main(){
  16. long long nod, n, a, b, find = 0;
  17. cin>>n>>a>>b;
  18. unsigned int x[n];
  19. for (int i = 0; i < n; i++)
  20. x[i] = nextRand32(a, b);
  21. for (int i = 0; i < n; i++)
  22. find += x[i];
  23. nod = __gcd(find, n);//ÍÎÄ
  24. find = find / nod;
  25. n = n / nod;
  26. cout<<find<<"/"<<n;
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement