結果

問題 No.65 回数の期待値の練習
ユーザー ooaiu
提出日時 2024-12-30 11:51:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 591 bytes
コンパイル時間 4,239 ms
コンパイル使用メモリ 244,932 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-30 11:51:28
合計ジャッジ時間 5,149 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef LOCAL
#include <bits/stdc++.h>

using namespace std;

#define debug(...) (void(0))
#else
#include "algo/debug.h"
#endif

void solve() {
    int K; cin >> K;
    vector<double> dp(K + 1);
    for(int i = K; i--; ) {
        dp[i] = 0;
        for(int j = 1; j <= 6; j++) {
            dp[i] += 1 + (i + j <= K ? dp[i + j] : 0);
        }
        dp[i] /= 6.;
    }
    cout << fixed << setprecision(16) << dp[0] << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int tt = 1;
    // std::cin >> tt;
    while (tt--) {
        solve();
    }
}
0