結果

問題 No.76 回数の期待値で練習
ユーザー GOTKAKO
提出日時 2025-06-30 01:18:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 14 ms / 5,000 ms
コード長 566 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 197,840 KB
実行使用メモリ 19,092 KB
最終ジャッジ日時 2025-06-30 01:18:37
合計ジャッジ時間 2,776 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

    vector<double> P = {0,1.0/12,1.0/6,1.0/4,1.0/12,1.0/4,1.0/6};
    vector<double> E(1000000),dp(1000000);
    double e = 0; dp.at(0) = 1;
    for(int i=0; i<1000000; i++){
        e += dp.at(i);
        E.at(i) = e;
        for(int k=1; k<=6&&i+k<1000000; k++) dp.at(i+k) += dp.at(i)*P.at(k);
    }
    int T; cin >> T;
    cout << fixed << setprecision(20);
    while(T--){
        int N; cin >> N;
        cout << E.at(N-1) << "\n";
    }

}
0