結果

問題 No.75 回数の期待値の問題
ユーザー siman
提出日時 2021-01-03 20:56:39
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 853 bytes
コンパイル時間 3,625 ms
コンパイル使用メモリ 139,260 KB
実行使用メモリ 13,768 KB
最終ジャッジ日時 2024-10-13 15:01:50
合計ジャッジ時間 32,461 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 TLE * 2 -- * 1
権限があれば一括ダウンロードができます

ソースコード

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