結果
問題 | No.1688 Veterinarian |
ユーザー |
![]() |
提出日時 | 2021-09-24 21:41:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 393 ms / 3,000 ms |
コード長 | 2,460 bytes |
コンパイル時間 | 3,309 ms |
コンパイル使用メモリ | 183,452 KB |
最終ジャッジ日時 | 2025-01-24 16:59:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #include <list> #include <atcoder/all> #define popcount __builtin_popcount using namespace std; using namespace atcoder; typedef long long ll; typedef pair<int, int> P; using mint=modint998244353; int a, b, c, n; double dp[51][51][51][51]; double p[51][51][51][51]; int main() { cin>>a>>b>>c>>n; for(int t=0; t<3; t++){ for(int i=0; i<=n; i++){ for(int j=0; j<=a; j++){ for(int k=0; k<=b; k++){ for(int l=0; l<=c; l++){ dp[i][j][k][l]=0; p[i][j][k][l]=0; } } } } double ans=0; p[0][a][b][c]=1; for(int i=0; i<n; i++){ for(int j=0; j<=a; j++){ for(int k=0; k<=b; k++){ for(int l=0; l<=c; l++){ int x=(j+k+l)*(j+k+l-1); if(x==0)continue; int y=j*(j-1), z=k*(k-1), w=l*(l-1); int u[3]={};u[t]++; if(j) p[i+1][j-1][k][l]+=p[i][j][k][l]*y/x; if(k) p[i+1][j][k-1][l]+=p[i][j][k][l]*z/x; if(l) p[i+1][j][k][l-1]+=p[i][j][k][l]*w/x; if(x) p[i+1][j][k][l]+=p[i][j][k][l]*(x-y-z-w)/x; if(j) dp[i+1][j-1][k][l]+=(dp[i][j][k][l]*y/x+p[i][j][k][l]*y/x*u[0]); if(k) dp[i+1][j][k-1][l]+=(dp[i][j][k][l]*z/x+p[i][j][k][l]*z/x*u[1]); if(l) dp[i+1][j][k][l-1]+=(dp[i][j][k][l]*w/x+p[i][j][k][l]*w/x*u[2]); if(x) dp[i+1][j][k][l]+=dp[i][j][k][l]*(x-y-z-w)/x; } } } } for(int j=0; j<=a; j++){ for(int k=0; k<=b; k++){ for(int l=0; l<=c; l++){ ans+=dp[n][j][k][l]; } } } printf("%.8lf", ans); if(t<2) cout<<" "; else cout<<endl; } return 0; }