結果

問題 No.65 回数の期待値の練習
ユーザー tetsuzuki1115
提出日時 2017-12-14 22:53:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 721 bytes
コンパイル時間 761 ms
コンパイル使用メモリ 79,676 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-14 13:35:16
合計ジャッジ時間 1,521 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


int K;
double memo[20];

double dfs( int x ) {
    
    if ( x >= K ) { return 0; }
    
    if ( memo[x] != -1 ) { return memo[x]; }
    
    memo[x] = dfs( x+1 ) / 6 + dfs( x+2 ) / 6 + dfs( x+3 ) / 6 
        + dfs( x+4 ) / 6 + dfs( x+5 ) / 6 + dfs( x+6 ) / 6 + 1;
    
    return memo[x];
}


int main() {
    
    cin >> K;
    fill( memo, memo+20, -1 );
    
    dfs(0);
    
    cout << memo[0] << endl;
    
    return 0;
}
0