結果

問題 No.1688 Veterinarian
ユーザー hourenhouren
提出日時 2021-09-24 22:32:17
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 3,000 ms
コード長 1,499 bytes
コンパイル時間 1,629 ms
コンパイル使用メモリ 175,880 KB
実行使用メモリ 61,044 KB
最終ジャッジ日時 2023-09-18 21:47:10
合計ジャッジ時間 2,754 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 6 ms
6,724 KB
testcase_08 AC 112 ms
61,044 KB
testcase_09 AC 104 ms
57,248 KB
testcase_10 AC 10 ms
8,124 KB
testcase_11 AC 12 ms
9,044 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 8 ms
6,592 KB
testcase_16 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
using P = pair<int,int>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()

int main(){
    int n,a,b,c;
    cin >> a >> b >> c >> n;
    vector<vector<vector<vector<double>>>> dp(n+1,vector<vector<vector<double>>>(a+1,vector<vector<double>>(b+1,vector<double>(c+1,0))));
    dp[0][a][b][c] = 1;
    rep(i,n){
        for(double j=1;j<=a;j++){
            for(double k=1;k<=b;k++){
                for(double l=1;l<=c;l++){
                    double na,nb,nc;
                    na = dp[i][j][k][l] * (j/(j+k+l)) * ((j-1)/(j+k+l-1));
                    nb = dp[i][j][k][l] * (k/(j+k+l)) * ((k-1)/(j+k+l-1));
                    nc = dp[i][j][k][l] * (l/(j+k+l)) * ((l-1)/(j+k+l-1));
                    //printf("%.6lf %.6lf %.6lf\n",na,nb,nc);
                    dp[i+1][j-1][k][l] += na;
                    dp[i+1][j][k-1][l] += nb;
                    dp[i+1][j][k][l-1] += nc;
                    dp[i+1][j][k][l] += dp[i][j][k][l] - na - nb - nc;
                }
            }
        }
    }
    double ansa = 0, ansb = 0, ansc = 0;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                ansa += (a-(double)i) * dp[n][i][j][k];
                ansb += (b-(double)j) * dp[n][i][j][k];
                ansc += (c-(double)k) * dp[n][i][j][k];
            }
        }
    }
    printf("%.12lf %.12lf %.12lf\n",ansa,ansb,ansc);
    return 0;
}
0