結果

問題 No.1688 Veterinarian
ユーザー tko919tko919
提出日時 2021-09-25 04:18:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 52 ms / 3,000 ms
コード長 1,443 bytes
コンパイル時間 2,134 ms
コンパイル使用メモリ 200,452 KB
実行使用メモリ 37,316 KB
最終ジャッジ日時 2023-09-18 22:48:27
合計ジャッジ時間 3,172 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 52 ms
37,316 KB
testcase_09 AC 48 ms
35,648 KB
testcase_10 AC 13 ms
11,912 KB
testcase_11 AC 6 ms
7,016 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 5 ms
5,784 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 13 ms
10,708 KB
testcase_16 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

double dp[51][51][51][51][3];
bool used[51][51][51][51];
void rec(int a,int b,int c,int n){
   if(used[a][b][c][n])return;
   used[a][b][c][n]=1;
   if(n==0)return;

   double rem=1;
   int m=a+b+c;
   if(a>=2){
      rec(a-1,b,c,n-1);
      rep(j,0,3){
         dp[a][b][c][n][j]+=(dp[a-1][b][c][n-1][j]+(j==0))*(a*(a-1))*1./(m*(m-1));
      }
      rem-=(a*(a-1))*1./(m*(m-1));
   }
   if(b>=2){
      rec(a,b-1,c,n-1);
      rep(j,0,3){
         dp[a][b][c][n][j]+=(dp[a][b-1][c][n-1][j]+(j==1))*(b*(b-1))*1./(m*(m-1));
      }
      rem-=(b*(b-1))*1./(m*(m-1));
   }
   if(c>=2){
      rec(a,b,c-1,n-1);
      rep(j,0,3){
         dp[a][b][c][n][j]+=(dp[a][b][c-1][n-1][j]+(j==2))*(c*(c-1))*1./(m*(m-1));
      }
      rem-=(c*(c-1))*1./(m*(m-1));
   }
   rec(a,b,c,n-1);
   rep(j,0,3){
      dp[a][b][c][n][j]+=(dp[a][b][c][n-1][j])*rem;
   }
   return;
}

int main(){
   int a,b,c,n;
   cin>>a>>b>>c>>n;
   rec(a,b,c,n);
   rep(i,0,3){
      printf("%.12f",dp[a][b][c][n][i]);
      cout<<(i==2?'\n':' ');
   }
   return 0;
}
0