結果
| 問題 | No.702 中央値を求めよ LIMITED | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2018-06-18 20:26:48 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,161 bytes | 
| コンパイル時間 | 649 ms | 
| コンパイル使用メモリ | 84,200 KB | 
| 実行使用メモリ | 13,880 KB | 
| 最終ジャッジ日時 | 2024-06-30 17:03:53 | 
| 合計ジャッジ時間 | 7,918 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 TLE * 1 | 
| other | -- * 25 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:57:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   57 |   scanf("%u", &seed);
      |   ~~~~~^~~~~~~~~~~~~
            
            ソースコード
/* -*- coding: utf-8 -*-
 *
 * 702.cc: No.702 中央値を求めよ LIMITED - yukicoder
 */
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;
/* constant */
const int N = 10000001;
const int MED = (N + 1) / 2;
const uint32_t UINF = ~0U;
/* typedef */
typedef uint32_t ui;
/* global variables */
ui x = 0, y = 1, z = 2, w = 3;
/* subroutines */
inline ui generate(ui &x, ui &y, ui &z, ui &w) {
  ui t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
  return w;
}
/* main */
int main() {
  ui seed;
  scanf("%u", &seed);
  ui l = 0, r = UINF;
  while (l + 1 < r) {
    ui m = (l + r) / 2;
    int cnt = 0;
    ui x = seed, y = 1, z = 2, w = 3;
    for (int i = 0; i < N; i++) {
      ui ai = generate(x, y, z, w);
      if (ai <= m) cnt++;
    }
    if (cnt >= MED) r = m;
    else l = m;
  }
  printf("%u\n", r);
  return 0;
}
            
            
            
        