結果
| 問題 | No.702 中央値を求めよ LIMITED |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-11-17 21:38:30 |
| 言語 | C++17(gcc12) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 697 ms / 5,000 ms |
| コード長 | 797 bytes |
| 記録 | |
| コンパイル時間 | 469 ms |
| コンパイル使用メモリ | 72,576 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-08 19:06:20 |
| 合計ジャッジ時間 | 17,715 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include<iostream>
#include<climits>
using namespace std;
uint32_t x = 0, y = 1, z = 2, w = 3;
int64_t seed;
void init(){
x = 0, y = 1, z = 2, w = 3;
x = 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;
}
bool check(uint32_t mid){
int cnt = 0;
init();
uint32_t tmp;
for(int i = 0; i < 10000001; i++){
tmp = generate();
if(tmp <= mid) cnt++;
}
return cnt >= 5000001;
}
typedef long long ll;
int main(){
cin >> seed;
uint32_t l = 0, r = UINT_MAX;
while(r != l){
uint32_t mid = l + (r-l)/2;
if(check(mid)) r = mid;
else l = mid+1;
}
cout << l << endl;
return 0;
}