結果

問題 No.1688 Veterinarian
ユーザー yakkiyakki
提出日時 2021-09-24 22:17:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 3,000 ms
コード長 1,722 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 120,268 KB
実行使用メモリ 64,944 KB
最終ジャッジ日時 2023-09-18 21:35:43
合計ジャッジ時間 2,231 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 6 ms
7,244 KB
testcase_07 AC 4 ms
4,684 KB
testcase_08 AC 103 ms
64,944 KB
testcase_09 AC 95 ms
62,588 KB
testcase_10 AC 16 ms
13,648 KB
testcase_11 AC 13 ms
11,072 KB
testcase_12 AC 3 ms
4,476 KB
testcase_13 AC 5 ms
6,716 KB
testcase_14 AC 4 ms
4,804 KB
testcase_15 AC 10 ms
9,900 KB
testcase_16 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<ctime>
//#include<atcoder/all>
using namespace std;
//using namespace atcoder;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0)

const double EPS = 1e-18;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
//using mint = modint998244353;

int dh[] = {-1,1,0,0};
int dw[] = {0,0,1,-1};


double dp[55][55][55][55];

int nC2(int n){
    return n*(n-1)/2;
}

int main(){
    int a,b,c,n; cin >> a >> b >> c >> n;
    dp[0][0][0][0] = 1;
    rep(i,n)rep(j,a+1)rep(k,b+1)rep(l,c+1){
        int sum = a-j + b-k + c-l;
        if(sum <= 1) continue;
        double p1 = (double)nC2(a-j)/nC2(sum);
        double p2 = (double)nC2(b-k)/nC2(sum);
        double p3 = (double)nC2(c-l)/nC2(sum);
        double p4 = 1.0-p1-p2-p3;
        dp[i+1][j][k][l] += p4*dp[i][j][k][l];
        dp[i+1][j+1][k][l] += p1*dp[i][j][k][l];
        dp[i+1][j][k+1][l] += p2*dp[i][j][k][l];
        dp[i+1][j][k][l+1] += p3*dp[i][j][k][l];

    }

    cout << fixed << setprecision(10);
    double ans1 = 0,ans2 = 0,ans3 = 0;
    rep(i,a+1)rep(j,b+1)rep(k,c+1){
        ans1 += dp[n][i][j][k]*i;
        ans2 += dp[n][i][j][k]*j;
        ans3 += dp[n][i][j][k]*k;
    }
    cout << ans1 << " " << ans2 << " " << ans3 << endl;
}
0