結果

問題 No.1688 Veterinarian
ユーザー zezerozezero
提出日時 2021-09-25 03:18:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,473 bytes
コンパイル時間 1,050 ms
コンパイル使用メモリ 105,128 KB
実行使用メモリ 57,576 KB
最終ジャッジ日時 2023-09-18 22:47:38
合計ジャッジ時間 2,066 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

double dp[52][52][52][52];

int choose(int x){return x*(x-1)/2;}

int main(){
    int A,B,C,N;
    cin >> A >> B >> C >> N;
    dp[0][A][B][C] = 1.0;
    for (int n = 0; n < N;n++){
        for (int a = 1; a <= A;a++){
            for (int b = 1; b <= B;b++){
                for (int c = 1; c <= C;c++){
                    int ex = choose(a+b+c)-choose(a)-choose(b)-choose(c);
                    int all = choose(a+b+c);
                    dp[n+1][a-1][b][c] += choose(a)*dp[n][a][b][c]/all;
                    dp[n+1][a][b-1][c] += choose(b)*dp[n][a][b][c]/all;
                    dp[n+1][a][b][c-1] += choose(c)*dp[n][a][b][c]/all;
                    dp[n+1][a][b][c] += ex*dp[n][a][b][c]/all; 
                }
            }
        }
    }
    double ansa = 0.0,ansb = 0.0,ansc = 0.0;
    for (int i = 1; i <= A;i++){
        for (int j = 1; j <= B;j++){
            for (int k = 1; k <= C;k++){
                ansa += dp[N][i][j][k]*(A-i);
                ansb += dp[N][i][j][k]*(B-j);
                ansc += dp[N][i][j][k]*(C-k);
            }
        }
    }
    cout << fixed << setprecision(10) << endl;
    cout << ansa << " " << ansb << " " << ansc << endl;
    

    return 0;
}
0