結果

問題 No.75 回数の期待値の問題
ユーザー t98slidert98slider
提出日時 2021-09-07 04:06:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 5,000 ms
コード長 388 bytes
コンパイル時間 1,459 ms
コンパイル使用メモリ 167,156 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-22 20:36:01
合計ジャッジ時間 2,492 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
    int K;
    cin>>K;
    double dp[K+1]={},temp;
    for(int k=0;k<=10000;k++){
        for(int i=0;i<K;i++){
            temp=1;
            for(int j=1;j<=6;j++){
                if(i+j>K)temp+=dp[0]/6;
                else temp+=dp[i+j]/6;
            }
            dp[i]=temp;
        }
    }
    printf("%.15lf\n",dp[0]);
}
0