#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, m, n) for(int i=int(m);i> 19)) ^ (t ^ (t >> 8)); return w; } void reset() { x = seed; y = 1; z = 2; w = 3; } //num以下の数が何回登場するか int count(ll num) { reset(); int ret = 0; for (int i = 0; i < 10000001; i++) { if (generate() <= num) ret++; } return ret; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> seed; x = seed; const int lim = 5000000; ll low = 0,high = (1ll << 32) - 1; int low_num = count(low); int high_num = count(high); int ii = 30; while(ii--){ // if(low_num < lim && high_num >= lim){ // break; // } ll mid = (low + high) / 2; int mid_num = count(mid); if(mid_num <= lim){ low_num = mid_num; low = mid; }else{ high_num = mid_num; high = mid; } } cout << high << endl; return 0; }