結果

問題 No.65 回数の期待値の練習
ユーザー GOTKAKO
提出日時 2025-06-29 22:14:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 406 bytes
コンパイル時間 2,085 ms
コンパイル使用メモリ 195,512 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2025-06-29 22:14:47
合計ジャッジ時間 2,388 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    double answer = 0;
    int K; cin >> K;
    vector<double> dp(K+1); dp.at(K) = 1;
    for(int i=K; i>0; i--){
        answer += dp.at(i);
        for(int k=1; k<=6; k++) if(i-k > 0) dp.at(i-k) += dp.at(i)*0.16666666;
    }

    cout << fixed << setprecision(20) << answer << endl;
}
0