結果

問題 No.1688 Veterinarian
ユーザー 👑 hitonanodehitonanode
提出日時 2021-09-24 22:33:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 3,000 ms
コード長 1,095 bytes
コンパイル時間 1,839 ms
コンパイル使用メモリ 79,716 KB
実行使用メモリ 4,660 KB
最終ジャッジ日時 2023-09-18 21:48:06
合計ジャッジ時間 2,085 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 4 ms
4,660 KB
testcase_08 AC 42 ms
4,620 KB
testcase_09 AC 39 ms
4,600 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 5 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,avx2")
#include <iomanip>
#include <iostream>
using namespace std;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

double dp[51][51][51];
double ret[3];

int main() {
    int A, B, C, N;
    cin >> A >> B >> C >> N;
    dp[A][B][C] = 1;

    for (int i = 0; i < N; i++) FOR(a, 1, A + 1) FOR(b, 1, B + 1) FOR(c, 1, C + 1) {
        double n = a + b + c;
        double paa = a * (a - 1) / (n * (n - 1));
        double pbb = b * (b - 1) / (n * (n - 1));
        double pcc = c * (c - 1) / (n * (n - 1));
        double p0 = 1 - paa - pbb - pcc;
        ret[0] += dp[a][b][c] * paa;
        ret[1] += dp[a][b][c] * pbb;
        ret[2] += dp[a][b][c] * pcc;
        dp[a - 1][b][c] += dp[a][b][c] * paa;
        dp[a][b - 1][c]  += dp[a][b][c] * pbb;
        dp[a][b][c - 1]  += dp[a][b][c] * pcc;
        dp[a][b][c] = dp[a][b][c] * p0;
    }
    cout << fixed << setprecision(16) << ret[0] << ' ' << ret[1] << ' ' << ret[2] << '\n';
}
0