結果
| 問題 |
No.1688 Veterinarian
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2021-09-24 22:22:02 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 269 ms / 3,000 ms |
| コード長 | 1,201 bytes |
| コンパイル時間 | 4,736 ms |
| コンパイル使用メモリ | 194,616 KB |
| 最終ジャッジ日時 | 2025-01-24 17:27:20 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
double f(ll x){
return (double)x*(x-1)/2;
}
double dp[52][52][52][52];
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int A,B,C,N;
cin>>A>>B>>C>>N;
dp[A][B][C][0]=1.0;
for(int i=0;i<N;i++){
for(int a=0;a<=A;a++){
for(int b=0;b<=B;b++){
for(int c=0;c<=C;c++){
if(f(a+b+c)==0){
dp[a][b][c][i+1]+=dp[a][b][c][i];
continue;
}
if(a>0) dp[a-1][b][c][i+1]+=dp[a][b][c][i]*f(a)/f(a+b+c);
if(b>0) dp[a][b-1][c][i+1]+=dp[a][b][c][i]*f(b)/f(a+b+c);
if(c>0) dp[a][b][c-1][i+1]+=dp[a][b][c][i]*f(c)/f(a+b+c);
dp[a][b][c][i+1]+=dp[a][b][c][i]*(1-(f(a)+f(b)+f(c))/f(a+b+c));
}
}
}
}
double asum=0,bsum=0,csum=0;
for(int a=0;a<=A;a++){
for(int b=0;b<=B;b++){
for(int c=0;c<=C;c++){
asum+=(A-a)*dp[a][b][c][N];
bsum+=(B-b)*dp[a][b][c][N];
csum+=(C-c)*dp[a][b][c][N];
}
}
}
cout<<fixed<<setprecision(10)<<asum<<" "<<bsum<<" "<<csum<<endl;
return 0;
}
umezo