結果
| 問題 |
No.1688 Veterinarian
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-06-03 17:52:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 448 ms / 3,000 ms |
| コード長 | 1,451 bytes |
| コンパイル時間 | 1,424 ms |
| コンパイル使用メモリ | 118,352 KB |
| 最終ジャッジ日時 | 2025-02-13 22:25:01 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
using ld = long double;
tuple<ld, ld, ld> tp = {-1, -1, -1};
vector<vector<vector<vector<tuple<ld, ld, ld>>>>> ans(51, vector(51, vector(51, vector<tuple<ld, ld, ld>>(51, tp))));
tuple<ld, ld, ld> f(int n, int a, int b, int c){
if (n == 0) return {0, 0, 0};
if (ans[n][a][b][c] != tp) return ans[n][a][b][c];
ld s = a+b+c, pa = a*(a-1)/s/(s-1), pb= b*(b-1)/s/(s-1), pc = c*(c-1)/s/(s-1);
ld x=0, y=0, z=0, xx, yy, zz;
tie(xx, yy, zz) = f(n-1, a, b, c);
x += xx * (1.0l-pa-pb-pc);
y += yy * (1.0l-pa-pb-pc);
z += zz * (1.0l-pa-pb-pc);
if (a>1){
tie(xx, yy, zz) = f(n-1, a-1, b, c);
x += (xx+1) * pa;
y += yy * pa;
z += zz * pa;
}
if (b>1){
tie(xx, yy, zz) = f(n-1, a, b-1, c);
x += xx * pb;
y += (yy+1) * pb;
z += zz * pb;
}
if (c>1){
tie(xx, yy, zz) = f(n-1, a, b, c-1);
x += xx * pc;
y += yy * pc;
z += (zz+1) * pc;
}
return ans[n][a][b][c] = {x, y, z};
}
int main(){
int a, b, c, n;
cin >> a >> b >> c >> n;
ld x, y, z;
tie(x, y, z) = f(n, a, b, c);
cout << setprecision(18) << x << " " << y << " " << z << endl;
return 0;
}
srjywrdnprkt