結果

問題 No.58 イカサマなサイコロ
ユーザー tsutajtsutaj
提出日時 2018-02-07 17:46:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 655 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 31,960 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-14 10:38:40
合計ジャッジ時間 1,053 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
using namespace std;
const int S = 100;
double dp[15][2*S];
int main() {
    int N, K; scanf("%d%d", &N, &K);
    dp[0][S] = 1.0;
    for(int i=0; i<N; i++) {
        for(int j=0; j<200; j++) {
            if(dp[i][j] == 0.0) continue;
            for(int A=1; A<=6; A++) {
                for(int x=0; x<6; x++) {
                    // 二郎君: A, 太郎君: B
                    int B = (i < K ? 4+(x/2) : x+1);
                    dp[i+1][j+(B-A)] += dp[i][j] / 36.0;
                }
            }
        }
    }

    double sum = 0.0;
    for(int i=S+1; i<2*S; i++) sum += dp[N][i];
    printf("%.12f\n", sum);
    return 0;
}
0