結果
問題 | No.1688 Veterinarian |
ユーザー | merom686 |
提出日時 | 2021-09-24 22:06:27 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 350 ms / 3,000 ms |
コード長 | 2,285 bytes |
コンパイル時間 | 1,973 ms |
コンパイル使用メモリ | 202,764 KB |
実行使用メモリ | 210,808 KB |
最終ジャッジ日時 | 2023-09-18 21:24:56 |
合計ジャッジ時間 | 3,577 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,624 KB |
testcase_01 | AC | 3 ms
6,220 KB |
testcase_02 | AC | 3 ms
6,268 KB |
testcase_03 | AC | 2 ms
5,684 KB |
testcase_04 | AC | 3 ms
5,528 KB |
testcase_05 | AC | 2 ms
5,684 KB |
testcase_06 | AC | 11 ms
13,688 KB |
testcase_07 | AC | 10 ms
9,856 KB |
testcase_08 | AC | 350 ms
210,808 KB |
testcase_09 | AC | 328 ms
204,700 KB |
testcase_10 | AC | 42 ms
33,920 KB |
testcase_11 | AC | 39 ms
29,188 KB |
testcase_12 | AC | 5 ms
7,784 KB |
testcase_13 | AC | 11 ms
13,324 KB |
testcase_14 | AC | 8 ms
9,360 KB |
testcase_15 | AC | 26 ms
21,708 KB |
testcase_16 | AC | 4 ms
6,680 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; double e[51][51][51][51][4]; int main() { int a, b, c, n; cin >> a >> b >> c >> n; e[n][a][b][c][3] = 1; for (int l = n; l > 0; l--) { for (int i = a; i > 0; i--) { for (int j = b; j > 0; j--) { for (int k = c; k > 0; k--) { double s = 1; int m = i + j + k; for (int h = 0; h < 3; h++) { int x = h == 0 ? i : h == 1 ? j : k; double t = (double)x * (x - 1) / (m * (m - 1)); if (h == 0) { for (int f = 0; f < 3; f++) { e[l - 1][i - 1][j][k][f] += (e[l][i][j][k][f] + e[l][i][j][k][3] * (f == h)) * t; } e[l - 1][i - 1][j][k][3] += e[l][i][j][k][3] * t; } else if (h == 1) { for (int f = 0; f < 3; f++) { e[l - 1][i][j - 1][k][f] += (e[l][i][j][k][f] + e[l][i][j][k][3] * (f == h)) * t; } e[l - 1][i][j - 1][k][3] += e[l][i][j][k][3] * t; } else if (h == 2) { for (int f = 0; f < 3; f++) { e[l - 1][i][j][k - 1][f] += (e[l][i][j][k][f] + e[l][i][j][k][3] * (f == h)) * t; } e[l - 1][i][j][k - 1][3] += e[l][i][j][k][3] * t; } s -= t; } for (int h = 0; h < 3; h++) { e[l - 1][i][j][k][h] += e[l][i][j][k][h] * s; } e[l - 1][i][j][k][3] += e[l][i][j][k][3] * s; } } } } double r[3] = {}; for (int i = a; i > 0; i--) { for (int j = b; j > 0; j--) { for (int k = c; k > 0; k--) { for (int h = 0; h < 3; h++) { r[h] += e[0][i][j][k][h]; } } } } cout << fixed << setprecision(9) << r[0] << ' ' << r[1] << ' ' << r[2] << endl; return 0; }