結果
| 問題 |
No.702 中央値を求めよ LIMITED
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-09-25 17:26:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 755 ms / 5,000 ms |
| コード長 | 798 bytes |
| コンパイル時間 | 1,610 ms |
| コンパイル使用メモリ | 166,224 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 22:53:15 |
| 合計ジャッジ時間 | 23,058 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
//pythonで解けないので、解く気はないのですが、問題一覧に表示されるのが面倒なので、尊敬する他の方のコードコピーさせていただきました。
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
uint32_t seed, x = 0, y = 1, z = 2, w = 3;
void init(){
x=seed;y=1;z=2;w=3;
}
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 N = 10000001;
Int calc(Int k){
init();
Int res=0;
for(Int i=0;i<N;i++)
res+=generate()<k;
return res;
};
signed main() {
cin >> seed;
Int l=0,r=1e10;
while(l+1<r){
Int m=(l+r)>>1;
if(calc(m)<=N/2) l=m;
else r=m;
}
cout<<l<<endl;
return 0;
}
mkawa2