結果

問題 No.58 イカサマなサイコロ
ユーザー KudeKude
提出日時 2020-09-07 06:21:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 390 ms / 5,000 ms
コード長 953 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 167,028 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 16:21:35
合計ジャッジ時間 2,618 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int n, k;
int c1[61], c2[61];

void dfs1(int m=0, int acc=0) {
    if (m == n) {
        c1[acc] += 1;
        return;
    }
    for(int i = 1; i <= 6; i++) dfs1(m+1, acc+i);
}

void dfs2(int m=0, int acc=0) {
    if (m == n) {
        c2[acc] += 1;
        return;
    }
    if (m < k) for(int i: {4,4,5,5,6,6}) dfs2(m+1, acc+i);
    else for(int i = 1; i <= 6; i++) dfs2(m+1, acc+i);
}

int main() {
    cin >> n >> k;
    dfs1();
    dfs2();
    for(int i = 59; i >= 0; i--) c2[i] += c2[i+1];
    ll wincnt = 0;
    rep(i, 60) wincnt += ll(c1[i]) * c2[i+1];
    ll totcnt = 1;
    rep(_, 2*n) totcnt *= 6;
    printf("%.8f\n", double(wincnt) / totcnt);
}
0