結果

問題 No.75 回数の期待値の問題
ユーザー nenuonnenuon
提出日時 2018-02-24 14:45:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 794 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 96,200 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-03 13:20:12
合計ジャッジ時間 2,064 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 17 ms
4,376 KB
testcase_17 AC 29 ms
4,376 KB
testcase_18 AC 34 ms
4,376 KB
testcase_19 AC 37 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <random>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// 二分探索var
// dp[0] = x
int K;
double dp[222];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> K;
  FOR(t,0,10000) {
    for(int i = K - 1; i >= 0; i--) {
      double tmp = 0;
    FOR(j,1,7) {
      if(i + j > K) tmp += dp[0];
      else tmp += dp[i+j];
    }
    dp[i] = tmp / 6.0 + 1;
  }
  }
  cout << dp[0] << endl;
}
0