結果
| 問題 |
No.1688 Veterinarian
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-25 03:18:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,473 bytes |
| コンパイル時間 | 1,371 ms |
| コンパイル使用メモリ | 105,520 KB |
| 最終ジャッジ日時 | 2025-01-24 18:02:00 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 14 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
double dp[52][52][52][52];
int choose(int x){return x*(x-1)/2;}
int main(){
int A,B,C,N;
cin >> A >> B >> C >> N;
dp[0][A][B][C] = 1.0;
for (int n = 0; n < N;n++){
for (int a = 1; a <= A;a++){
for (int b = 1; b <= B;b++){
for (int c = 1; c <= C;c++){
int ex = choose(a+b+c)-choose(a)-choose(b)-choose(c);
int all = choose(a+b+c);
dp[n+1][a-1][b][c] += choose(a)*dp[n][a][b][c]/all;
dp[n+1][a][b-1][c] += choose(b)*dp[n][a][b][c]/all;
dp[n+1][a][b][c-1] += choose(c)*dp[n][a][b][c]/all;
dp[n+1][a][b][c] += ex*dp[n][a][b][c]/all;
}
}
}
}
double ansa = 0.0,ansb = 0.0,ansc = 0.0;
for (int i = 1; i <= A;i++){
for (int j = 1; j <= B;j++){
for (int k = 1; k <= C;k++){
ansa += dp[N][i][j][k]*(A-i);
ansb += dp[N][i][j][k]*(B-j);
ansc += dp[N][i][j][k]*(C-k);
}
}
}
cout << fixed << setprecision(10) << endl;
cout << ansa << " " << ansb << " " << ansc << endl;
return 0;
}