結果

問題 No.1688 Veterinarian
ユーザー monnumonnu
提出日時 2021-10-02 09:46:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 104 ms / 3,000 ms
コード長 1,463 bytes
コンパイル時間 3,862 ms
コンパイル使用メモリ 234,988 KB
実行使用メモリ 61,160 KB
最終ジャッジ日時 2023-09-27 09:25:24
合計ジャッジ時間 5,278 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 5 ms
6,748 KB
testcase_08 AC 104 ms
61,160 KB
testcase_09 AC 98 ms
57,136 KB
testcase_10 AC 9 ms
8,180 KB
testcase_11 AC 10 ms
9,204 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,452 KB
testcase_15 AC 7 ms
6,260 KB
testcase_16 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 20005
//#define MOD 1000000007
#define MOD 998244353
//#define INF 1000000000
#define INF 1000000000000000000

int main(){
  int A,B,C,N;
  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.0))));
  dp[0][A][B][C]=1.0;
  for(int cnt=0;cnt<N;cnt++){
    for(int i=1;i<=A;i++){
      for(int j=1;j<=B;j++){
        for(int k=1;k<=C;k++){
          int sum=i+j+k;
          double p1=(double)i*((double)i-1.0)/(double)sum/((double)sum-1.0);
          double p2=(double)j*((double)j-1.0)/(double)sum/((double)sum-1.0);
          double p3=(double)k*((double)k-1.0)/(double)sum/((double)sum-1.0);
          dp[cnt+1][i-1][j][k]+=dp[cnt][i][j][k]*p1;
          dp[cnt+1][i][j-1][k]+=dp[cnt][i][j][k]*p2;
          dp[cnt+1][i][j][k-1]+=dp[cnt][i][j][k]*p3;
          dp[cnt+1][i][j][k]+=dp[cnt][i][j][k]*(1.0-p1-p2-p3);
        }
      }
    }
  }

  double ans1=0.0;
  double ans2=0.0;
  double ans3=0.0;
  for(int i=1;i<=A;i++){
    for(int j=1;j<=B;j++){
      for(int k=1;k<=C;k++){
        ans1+=dp[N][i][j][k]*((double)A-(double)i);
        ans2+=dp[N][i][j][k]*((double)B-(double)j);
        ans3+=dp[N][i][j][k]*((double)C-(double)k);
      }
    }
  }

  printf("%.9lf %.9lf %.9lf\n",ans1,ans2,ans3);
}
0