結果

問題 No.1688 Veterinarian
ユーザー olpheolphe
提出日時 2021-09-24 21:34:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 3,000 ms
コード長 1,996 bytes
コンパイル時間 1,212 ms
コンパイル使用メモリ 128,304 KB
実行使用メモリ 7,704 KB
最終ジャッジ日時 2023-09-18 20:49:02
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,500 KB
testcase_01 AC 2 ms
5,556 KB
testcase_02 AC 2 ms
5,620 KB
testcase_03 AC 2 ms
5,568 KB
testcase_04 AC 2 ms
5,744 KB
testcase_05 AC 2 ms
5,640 KB
testcase_06 AC 2 ms
5,636 KB
testcase_07 AC 8 ms
7,704 KB
testcase_08 AC 101 ms
7,644 KB
testcase_09 AC 93 ms
7,616 KB
testcase_10 AC 9 ms
6,100 KB
testcase_11 AC 11 ms
6,164 KB
testcase_12 AC 4 ms
6,252 KB
testcase_13 AC 3 ms
5,800 KB
testcase_14 AC 4 ms
5,784 KB
testcase_15 AC 6 ms
5,744 KB
testcase_16 AC 3 ms
5,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0