結果

問題 No.75 回数の期待値の問題
ユーザー uenokuuenoku
提出日時 2017-01-14 23:15:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 588 ms
コンパイル使用メモリ 76,476 KB
実行使用メモリ 36,432 KB
最終ジャッジ日時 2023-08-23 10:47:20
合計ジャッジ時間 2,353 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
36,360 KB
testcase_01 AC 46 ms
36,372 KB
testcase_02 AC 35 ms
36,412 KB
testcase_03 AC 36 ms
36,252 KB
testcase_04 AC 35 ms
36,412 KB
testcase_05 AC 35 ms
36,432 KB
testcase_06 AC 36 ms
36,248 KB
testcase_07 AC 36 ms
36,376 KB
testcase_08 AC 37 ms
36,268 KB
testcase_09 AC 37 ms
36,248 KB
testcase_10 AC 38 ms
36,268 KB
testcase_11 AC 38 ms
36,376 KB
testcase_12 AC 39 ms
36,424 KB
testcase_13 AC 39 ms
36,276 KB
testcase_14 AC 39 ms
36,248 KB
testcase_15 AC 41 ms
36,424 KB
testcase_16 AC 46 ms
36,300 KB
testcase_17 AC 54 ms
36,252 KB
testcase_18 AC 60 ms
36,256 KB
testcase_19 AC 61 ms
36,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define mp make_pair
using namespace std;
typedef long long int lli;
lli MOD = 1000000007;
double pos[20010][210] = {};
int main()
{
    pos[0][0] = 1;
    int k;
    cin >> k;
    rep(i, 20000) rep(j, k)
    {
        for (int l = 1; l <= 6; l++) {
            int a = l + j;
            if (a > k)
                a = 0;
            pos[i + 1][a] += 1.0 / 6.0 * pos[i][j];
        }
    }
    double ans = 0;
    rep(i, 20000) ans += i * pos[i][k];
    printf("%.10f\n", ans);
}
0