結果
| 問題 |
No.1688 Veterinarian
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-24 21:34:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 119 ms / 3,000 ms |
| コード長 | 1,996 bytes |
| コンパイル時間 | 1,149 ms |
| コンパイル使用メモリ | 125,980 KB |
| 最終ジャッジ日時 | 2025-01-24 16:53:44 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
using namespace std;
//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;
//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;
long double dp[51][51][51] = {};
long double ndp[51][51][51] = {};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int a, b, c;
cin >> a >> b >> c >> N;
dp[a][b][c] = 1;
while (N--) {
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= b; j++) {
for (int k = 1; k <= c; k++) {
long double num = i + j + k;
long double amari = 1;
{
long double p = i * (i - 1);
p /= num;
p /= num - 1;
ndp[i - 1][j][k] += dp[i][j][k] * p;
amari -= p;
}
{
long double p = j * (j - 1);
p /= num;
p /= num - 1;
ndp[i][j - 1][k] += dp[i][j][k] * p;
amari -= p;
}
{
long double p = k * (k - 1);
p /= num;
p /= num - 1;
ndp[i][j][k - 1] += dp[i][j][k] * p;
amari -= p;
}
ndp[i][j][k] = dp[i][j][k] * amari;
}
}
}
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= b; j++) {
for (int k = 1; k <= c; k++) {
dp[i][j][k] = ndp[i][j][k];
ndp[i][j][k] = 0;
}
}
}
}
long double d = 0, e = 0, f = 0;
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= b; j++) {
for (int k = 1; k <= c; k++) {
d += dp[i][j][k] * (a - i);
e += dp[i][j][k] * (b - j);
f += dp[i][j][k] * (c - k);
}
}
}
cout << fixed << setprecision(20) << d << " " << e << " " << f << endl;
}