結果

問題 No.75 回数の期待値の問題
ユーザー simansiman
提出日時 2021-01-03 20:56:39
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 853 bytes
コンパイル時間 7,082 ms
コンパイル使用メモリ 139,768 KB
実行使用メモリ 9,888 KB
最終ジャッジ日時 2024-04-21 16:05:09
合計ジャッジ時間 27,145 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 427 ms
9,888 KB
testcase_01 AC 541 ms
6,940 KB
testcase_02 AC 638 ms
6,940 KB
testcase_03 AC 886 ms
6,940 KB
testcase_04 AC 662 ms
6,944 KB
testcase_05 AC 628 ms
6,944 KB
testcase_06 AC 575 ms
6,940 KB
testcase_07 AC 876 ms
6,940 KB
testcase_08 AC 879 ms
6,940 KB
testcase_09 AC 878 ms
6,940 KB
testcase_10 AC 902 ms
6,940 KB
testcase_11 AC 940 ms
6,940 KB
testcase_12 AC 1,036 ms
6,944 KB
testcase_13 AC 1,036 ms
6,940 KB
testcase_14 AC 1,081 ms
6,944 KB
testcase_15 AC 1,256 ms
6,944 KB
testcase_16 AC 3,400 ms
6,940 KB
testcase_17 TLE -
testcase_18 TLE -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

unsigned long long xor128() {
  static unsigned long long rx = 123456789, ry = 362436069, rz = 521288629, rw = 88675123;
  unsigned long long rt = (rx ^ (rx << 11));
  rx = ry;
  ry = rz;
  rz = rw;
  return (rw = (rw ^ (rw >> 19)) ^ (rt ^ (rt >> 8)));
}

int main() {
  int K;
  cin >> K;

  ll loop_cnt = 10000000;
  ll sum = 0;

  for (int i = 0; i < loop_cnt; ++i) {
    int n = 0;
    int cnt = 0;

    while (n < K) {
      n += (xor128() % 6) + 1;
      if (n > K) n = 0;
      ++cnt;
    }

    sum += cnt;
  }

  cout << fixed << setprecision(10) << sum / (double) loop_cnt << endl;

  return 0;
}
0