結果

問題 No.574 正多面体サイコロ
ユーザー nebukuro09nebukuro09
提出日時 2018-04-11 09:34:36
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 1,285 bytes
コンパイル時間 2,238 ms
コンパイル使用メモリ 157,468 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 19:16:10
合計ジャッジ時間 4,411 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 9 ms
4,376 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 22 ms
4,380 KB
testcase_10 AC 29 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 4 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 5 ms
4,376 KB
testcase_15 AC 2 ms
4,384 KB
testcase_16 AC 1 ms
4,384 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 28 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 91 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!long);
    auto F = s[0];
    auto N = s[1];
    auto K = s[2];
    real ans = 0;

    foreach (i; 1..F+1) { // 上からK番目の出目
        foreach (a; 0..N+1) { // iより小さい目が出た回数
            foreach (b; 0..N+1) { // iより大きい目が出た回数
                auto c = N - a - b; // iの目が出た回数
                if (i == 1 && a != 0) continue;
                if (i == F && b != 0) continue;
                if (c < 1) continue;
                if (b >= K || b + c < K) continue;
                long A = i - 1;
                long B = F - i;
                real tmp = 1;
                foreach (k; 1..a+1) tmp = tmp * A / F;
                foreach (k; 1..b+1) tmp = tmp * B / F;
                foreach (k; 1..c+1) tmp = tmp * 1 / F;
                foreach (k; 1..a+1) tmp = tmp * k / k;
                foreach (k; 1..b+1) tmp = tmp * (k + a) / k;
                foreach (k; 1..c+1) tmp = tmp * (k + a + b) / k;
                ans += tmp * i;
            }
        }
    }

    writefln("%.09f", ans);
}
0