結果
問題 |
No.1688 Veterinarian
|
ユーザー |
![]() |
提出日時 | 2021-10-02 09:46:47 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 121 ms / 3,000 ms |
コード長 | 1,463 bytes |
コンパイル時間 | 4,268 ms |
コンパイル使用メモリ | 236,744 KB |
実行使用メモリ | 61,568 KB |
最終ジャッジ日時 | 2024-07-20 03:34:07 |
合計ジャッジ時間 | 5,527 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#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); }