結果
問題 | No.702 中央値を求めよ LIMITED |
ユーザー |
![]() |
提出日時 | 2018-06-15 22:55:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 501 ms / 5,000 ms |
コード長 | 825 bytes |
コンパイル時間 | 1,752 ms |
コンパイル使用メモリ | 166,284 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 22:04:46 |
合計ジャッジ時間 | 16,056 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; uint32_t x = 0, y = 1, z = 2, w = 3; uint32_t seed; inline uint32_t generate() { uint32_t t = (x^(x<<11)); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); return w; } const int a = 10000001; inline void init() { x = seed; y = 1; z = 2; w = 3; } int main() { cin >> seed; uint32_t high = UINT32_MAX, low = 0; while (high - low > 1) { const uint32_t mid = low + (high - low) / 2; init(); int cnt = 0; bool isExist = false; for (int i = 0; i < a; i++) { if (generate() <= mid) { cnt++; } } if (cnt <= a / 2) { low = mid; } else { high = mid; } } cout << high << endl; }