結果

問題 No.58 イカサマなサイコロ
ユーザー けーむけーむ
提出日時 2020-12-26 16:32:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,704 bytes
コンパイル時間 1,811 ms
コンパイル使用メモリ 174,732 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 00:25:59
合計ジャッジ時間 2,453 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }
long long gcd(long long a, long long b) { return (a % b) ? gcd(b, a % b) : b; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    ll mv = 6 * n;
    vector<vector<vector<ll>>> dp(n + 1, vector<vector<ll>>(mv + 1, vector<ll>(mv + 1, 0)));
    dp[0][0][0] = 1;
    rep(i, n) {
        reps(ts, 1, 7) {
            reps(js, 1, 7) {
                ll tsj = ts + (((i < k) && (ts <= 3)) ? 3 : 0);
                ll jsj = js;
                reps(tn, tsj, mv + 1) {
                    reps(jn, jsj, mv + 1) {
                        dp[i + 1][tn][jn] += dp[i][tn - tsj][jn - jsj];
                    }
                }
            }
        }
    }
    ll tot = 0;
    rep(i, mv + 1) {
        rep(j, mv + 1) {
            if (i > j) {
                tot += dp[n][i][j];
            }
        }
    }
    double rij = 1;
    rep(i, n) rij *= 36;
    double ans = tot / rij;
    printf("%.10f\n", ans);
    return 0;
}
0