結果

問題 No.1688 Veterinarian
ユーザー ぷらぷら
提出日時 2021-09-24 22:13:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 3,000 ms
コード長 1,719 bytes
コンパイル時間 2,922 ms
コンパイル使用メモリ 201,372 KB
実行使用メモリ 55,380 KB
最終ジャッジ日時 2023-09-18 21:31:46
合計ジャッジ時間 3,984 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 4 ms
5,724 KB
testcase_07 AC 4 ms
4,708 KB
testcase_08 AC 98 ms
55,380 KB
testcase_09 AC 92 ms
53,588 KB
testcase_10 AC 14 ms
12,352 KB
testcase_11 AC 12 ms
9,668 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 5 ms
6,252 KB
testcase_14 AC 3 ms
4,736 KB
testcase_15 AC 9 ms
8,760 KB
testcase_16 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

double dp[51][51][51][51];

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    dp[0][a][b][c] = 1;
    for(int i = 0; i < d; i++) {
        for(int j = 0; j <= a; j++) {
            for(int k = 0; k <= b; k++) {
                for(int l = 0; l <= c; l++) {
                    if(j+k+l <= 1) {
                        continue;
                    }
                    double pp = 1;
                    if(j) {
                        double p = 1;
                        p *= (double)(j*(j-1))/((j+k+l)*(j+k+l-1));
                        dp[i+1][j-1][k][l] += dp[i][j][k][l]*p;
                        pp -= p;
                    }
                    if(k) {
                        double p = 1;
                        p *= (double)(k*(k-1))/((j+k+l)*(j+k+l-1));
                        dp[i+1][j][k-1][l] += dp[i][j][k][l]*p;
                        pp -= p;
                    }
                    if(l) {
                        double p = 1;
                        p *= (double)(l*(l-1))/((j+k+l)*(j+k+l-1));
                        dp[i+1][j][k][l-1] += dp[i][j][k][l]*p;
                        pp -= p;
                    }
                    dp[i+1][j][k][l] += dp[i][j][k][l]*pp;
                }
            }
        }
    }
    double ans1 = 0,ans2 = 0,ans3 = 0;
    for(int i = 0; i <= a; i++) {
        for(int j = 0; j <= b; j++) {
            for(int k = 0; k <= c; k++) {
                ans1 += (a-i)*dp[d][i][j][k];
                ans2 += (b-j)*dp[d][i][j][k];
                ans3 += (c-k)*dp[d][i][j][k];
            }
        }
    }
    cout << fixed << setprecision(18) << ans1 << " " << ans2 << " " << ans3 << endl;
}
0