結果
問題 | No.574 正多面体サイコロ |
ユーザー |
|
提出日時 | 2018-04-11 09:34:36 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 1,285 bytes |
コンパイル時間 | 2,662 ms |
コンパイル使用メモリ | 160,368 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-13 00:19:49 |
合計ジャッジ時間 | 3,363 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
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);}