Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstring>
  3. using namespace std;
  4. long long twist(long long u,long long v)
  5. {
  6. return (((u & 0x80000000L) | (v & 0x7fffffffL)) >> 1) ^ ((v & 1) == 1 ? 0x9908b0dfL : 0);
  7. }
  8. long long state[624];
  9. int left=1;
  10.  
  11. void next_state()
  12. {
  13. int p = 0;
  14. left = 624;
  15. for (int j = 228; --j > 0; p++)
  16. state[p] = state[p+397] ^ twist(state[p], state[p + 1]);
  17.  
  18. for (int j=397;--j>0;p++)
  19. state[p] = state[p-227] ^ twist(state[p], state[p + 1]);
  20.  
  21. state[p] = state[p-227] ^ twist(state[p], state[0]);
  22. }
  23. long long next()
  24. {
  25. if (--left == 0) next_state();
  26. return state[624-left];
  27. }
  28. int main()
  29. {
  30. for(int j=1;j<624;j++)
  31. {
  32. state[j] = (1812433253L * (state[j - 1] ^ (state[j - 1] >> 30)) + j);
  33. state[j] &= 0xffffffffL;
  34. }
  35. for(long long i=0;i<5000000000L;i++)
  36. {
  37. printf("%lld\n",next());
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement