結果

問題 No.75 回数の期待値の問題
ユーザー nenuon
提出日時 2018-02-24 14:45:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 794 bytes
コンパイル時間 875 ms
コンパイル使用メモリ 96,864 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-13 10:03:03
合計ジャッジ時間 1,740 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

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