結果

問題 No.702 中央値を求めよ LIMITED
ユーザー 👑 obakyanobakyan
提出日時 2019-04-29 17:23:14
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,155 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 71,008 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-14 21:51:51
合計ジャッジ時間 52,217 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,742 ms
4,380 KB
testcase_01 AC 1,828 ms
4,380 KB
testcase_02 AC 1,825 ms
4,376 KB
testcase_03 AC 1,826 ms
4,380 KB
testcase_04 AC 1,801 ms
4,376 KB
testcase_05 AC 1,806 ms
4,376 KB
testcase_06 AC 1,826 ms
4,376 KB
testcase_07 AC 1,825 ms
4,380 KB
testcase_08 AC 1,826 ms
4,380 KB
testcase_09 AC 1,772 ms
4,376 KB
testcase_10 AC 1,827 ms
4,380 KB
testcase_11 AC 1,827 ms
4,380 KB
testcase_12 AC 1,712 ms
4,380 KB
testcase_13 AC 1,863 ms
4,380 KB
testcase_14 AC 1,770 ms
4,376 KB
testcase_15 AC 1,711 ms
4,376 KB
testcase_16 AC 1,826 ms
4,380 KB
testcase_17 AC 1,858 ms
4,376 KB
testcase_18 AC 1,825 ms
4,376 KB
testcase_19 AC 1,743 ms
4,376 KB
testcase_20 AC 1,768 ms
4,376 KB
testcase_21 AC 1,802 ms
4,384 KB
testcase_22 AC 1,859 ms
4,380 KB
testcase_23 AC 1,804 ms
4,376 KB
testcase_24 AC 1,805 ms
4,376 KB
testcase_25 AC 1,767 ms
4,376 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <cstddef>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <iostream>
#include <iomanip>
#define L64 long long
#define MOD (1000000007LL)

uint32_t x = 0, y = 1, z = 2, w = 3;
int64_t g_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;
}

int check(uint32_t a, bool& same){
  same = false;
  uint32_t q;
  int ret = 0;
  x = g_seed;
  y = 1;
  z = 2;
  w = 3;
  for (int i = 0; i < 10000001; i++){
    q = generate();
    if(q < a){
      ret++;
    } else if(q == a){ same = true; }
  }
  return ret;
}

int main(void)
{
  bool same = false;
  std::cin >> g_seed;
  uint32_t min, max;
  min = 0; max = 4294967295;
  while(min != max){
    uint32_t mid = (uint32_t)((((uint64_t)min + (uint64_t)max) / (uint64_t)2));
    int lownum = check(mid, same);
    if(lownum < 5000000){
      min = mid + 1;
    } else if(lownum == 5000000){
      if(same){
        std::cout << mid << std::endl;
        break;
      } else {
        min = mid + 1;
      }
    } else {
      max = mid;
    }
  }
}
0