結果
| 問題 |
No.1688 Veterinarian
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2021-09-25 02:40:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 3,000 ms |
| コード長 | 1,630 bytes |
| コンパイル時間 | 863 ms |
| コンパイル使用メモリ | 96,144 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-07-05 11:57:04 |
| 合計ジャッジ時間 | 1,583 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1688.cc: No.1688 Veterinarian - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 50;
const int MAX_A = 50;
const int MAX_B = 50;
const int MAX_C = 50;
/* typedef */
/* global variables */
double dp[MAX_N + 1][MAX_A + 1][MAX_B + 1][MAX_C + 1];
/* subroutines */
inline int nc2(int n) { return n * (n - 1) / 2; }
/* main */
int main() {
int a, b, c, n;
scanf("%d%d%d%d", &a, &b, &c, &n);
dp[0][a][b][c] = 1.0;
for (int i = 0; i < n; i++)
for (int x = a; x > 0; x--) {
int a2 = nc2(x);
for (int y = b; y > 0; y--) {
int b2 = nc2(y);
for (int z = c; z > 0; z--)
if (dp[i][x][y][z] > 0.0) {
int s2 = nc2(x + y + z), c2 = nc2(z);
dp[i + 1][x - 1][y][z] += dp[i][x][y][z] * a2 / s2;
dp[i + 1][x][y - 1][z] += dp[i][x][y][z] * b2 / s2;
dp[i + 1][x][y][z - 1] += dp[i][x][y][z] * c2 / s2;
dp[i + 1][x][y][z] += dp[i][x][y][z] * (s2 - (a2 + b2 + c2)) / s2;
}
}
}
double ea = 0.0, eb = 0.0, ec = 0.0;
for (int x = a; x > 0; x--)
for (int y = b; y > 0; y--)
for (int z = c; z > 0; z--)
if (dp[n][x][y][z] > 0.0) {
ea += dp[n][x][y][z] * (a - x);
eb += dp[n][x][y][z] * (b - y);
ec += dp[n][x][y][z] * (c - z);
}
printf("%.16lf %.16lf %.16lf\n", ea, eb, ec);
return 0;
}
tnakao0123