結果

問題 No.108 トリプルカードコンプ
ユーザー nebukuro09nebukuro09
提出日時 2016-11-12 11:50:55
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 156,068 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-09-02 22:53:51
合計ジャッジ時間 3,411 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;

void main() {
  int N = readln.chomp.to!int;
  auto A = readln.split.map!(to!int);
  int[4] count;
  foreach (a; A)
    count[min(a, 3)] += 1;

  auto dp = new double[][][](count[0]+1, count[1]+1, count[2]+1);
  dp[0][0][0] = 0.0;

  foreach (i; iota(count[0]+1))
    foreach (j; iota(count[1]+1))
      foreach (k; iota(count[2]+1)) {
        if (i+j+k == 0)
          continue;
        dp[i][j][k] = N*1.0/(i+j+k);
        if (k-1 >= 0)
          dp[i][j][k] += dp[i][j][k-1] * (k*1.0/(i+j+k));
        if (j-1 >= 0 && k+1 <= count[2])
          dp[i][j][k] += dp[i][j-1][k+1] * (j*1.0/(i+j+k));
        if (i-1 >= 0 && j+1 <= count[1])
          dp[i][j][k] += dp[i-1][j+1][k] * (i*1.0/(i+j+k));
      }
            
  writef("%.07f", dp[count[0]][count[1]][count[2]]);
}
0