結果
| 問題 | No.702 中央値を求めよ LIMITED |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2018-06-18 20:28:57 |
| 言語 | C++11(old_compat) (gcc 12.4.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 947 ms / 5,000 ms |
| コード長 | 1,169 bytes |
| 記録 | |
| コンパイル時間 | 1,262 ms |
| コンパイル使用メモリ | 165,296 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2026-03-08 16:17:42 |
| 合計ジャッジ時間 | 26,191 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:56:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
56 | 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;
/* typedef */
typedef uint32_t ui;
typedef long long ll;
/* 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);
ll l = -1, r = (1LL << 32) - 1;
while (l + 1 < r) {
ll 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("%lld\n", r);
return 0;
}
tnakao0123