Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- using namespace std;
- inline int next(int x0) // next element of the sequence
- {
- return (214013*x0 + 2531011); // some magic numbers from wikipedia
- }
- inline int random(int x0)
- {
- return (next(x0) & 0x7FFF0000) >> 16;
- }
- int main()
- {
- int a, b, c;
- scanf("%d %d %d", &a, &b, &c); // read 3 first numbers from the sequence
- int x0;
- for (int i = 0x0000; i < 0xFFFF; i++) // small, but still brute force
- {
- x0 = (a << 16) | i; // new candidate
- if (b == random(x0) && c == random(next(x0))) // we found our element, comparing only with b gives 50% success rate
- {
- break;
- }
- }
- x0 = next(x0);
- for (;;) // and the 'random' sequence follows...
- {
- getchar();
- x0 = next(x0);
- printf("%d", random(x0));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement