Untitled
unknown
plain_text
a year ago
1.6 kB
5
Indexable
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; using ll = long long; template<class T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int dx[] = {0, 0, 1, -1, 1, 1, -1, -1}; int dy[] = {1, -1, 0, 0, 1, -1, 1, -1}; void File() { ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("errors.txt", "w", stderr); #else #endif } long double dp[102][102][102]; int main() { File(); int a[3]; cin >> a[0] >> a[1] >> a[2]; dp[a[0]][a[1]][a[2]] = 1; for (int i = a[0]; i >= 0; --i) { for (int j = a[1]; j >= 0; --j) { for (int k = a[2]; k >= 0; --k) { for (int l = 1; l < (1 << 3); l <<= 1) { ll x = i + (l & 1), y = j + ((l >> 1) & 1), z = k + ((l >> 2) & 1); long double all = (x + y + z) * (x + y + z - 1) / 2; long double rem = all - x * (x - 1) / 2 - y * (y - 1) / 2 - z * (z - 1) / 2; dp[i][j][k] += dp[x][y][z] * (rem / all); } } } } cerr << dp[2][2][1] << "\n"; for (int i = 0; i < 3; ++i) { long double res = 0; for (int j = 1; j <= a[i]; ++j) res += dp[i == 0][i == 1][i == 2]; cout << res << " "; } return 0; }
Editor is loading...
Leave a Comment