結果

問題 No.58 イカサマなサイコロ
ユーザー kpinkcatkpinkcat
提出日時 2023-10-14 19:19:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,237 bytes
コンパイル時間 1,203 ms
コンパイル使用メモリ 108,084 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-14 19:19:58
合計ジャッジ時間 1,822 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main(){
    int n, k;
    double anst = 0;
    cin >> n >> k;
    vector<vector<double>> taro(n+1, vector<double>(n*6+1)), jiro(n+1, vector<double>(n*6+1));
    taro[0][0] = 1.0, jiro[0][0] = 1.0;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= i*6; j++){
            if (k >= i){
                for (int l = 4; l <= 6; l++){
                    if (j - l >= 0) taro[i][j] += taro[i-1][j-l]/3;
                }
                for (int l = 1; l <= 6; l++){
                    if (j - l >= 0) jiro[i][j] += jiro[i-1][j-l]/6;
                }
            } else {
                for (int l = 1; l <= 6; l++){
                    if (j - l >= 0){
                        taro[i][j] += taro[i-1][j-l]/6;
                        jiro[i][j] += jiro[i-1][j-l]/6;
                    }
                }
            }
            
        }
    }
    for (int i = 1; i <= n*6; i++){
        for (int j = 1; j < i; j++){
            anst += taro[n][i]*jiro[n][j];
        }
    }
    cout << anst << endl;
}
0