結果
問題 | No.702 中央値を求めよ LIMITED |
ユーザー |
|
提出日時 | 2018-07-06 11:12:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 637 ms / 5,000 ms |
コード長 | 749 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 39,552 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-22 22:33:42 |
合計ジャッジ時間 | 19,183 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <climits> #include <cmath> #include <cstdio> using namespace std; using i64 = long long; using u32 = unsigned int; constexpr int N = int(powl(10, 7)) + 1; u32 x, y, z, w; u32 generate() { u32 t = (x^(x<<11)); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); return w; } int f(i64 a, u32 seed) { ::x = seed; ::y = 1; ::z = 2; ::w = 3; int cnt = 0; for(int i=0; i<N; ++i) { if(generate() <= a) { ++cnt; } } return cnt; } int main(void) { u32 seed; scanf("%u", &seed); i64 lo = 0, hi = UINT_MAX; while(hi - lo > 1) { i64 md = (lo + hi) / 2; if(f(md, seed) >= (N+1) / 2) { hi = md; } else { lo = md; } } printf("%lld\n", hi); return 0; }