#include #include #include #include #include #include #include #include #include #define L64 long long #define MOD (1000000007LL) uint32_t x = 0, y = 1, z = 2, w = 3; int64_t g_seed; uint32_t generate() { uint32_t t = (x^(x<<11)); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); return w; } int check(uint32_t a, bool& same){ same = false; uint32_t q; int ret = 0; x = g_seed; y = 1; z = 2; w = 3; for (int i = 0; i < 10000001; i++){ q = generate(); if(q < a){ ret++; } else if(q == a){ same = true; } } return ret; } int main(void) { bool same = false; std::cin >> g_seed; uint32_t min, max; min = 0; max = 4294967295; while(min != max){ uint32_t mid = (uint32_t)((((uint64_t)min + (uint64_t)max) / (uint64_t)2)); int lownum = check(mid, same); if(lownum < 5000000){ min = mid + 1; } else if(lownum == 5000000){ if(same){ std::cout << mid << std::endl; break; } else { min = mid + 1; } } else { max = mid; } } }