Test instructions and analysis (codeforces 540D) code
#include <iomanip> #include <iostream> #include <cstring> #include <algorithm> #include < vector> #define MP make_pair#define PB push_back#define fi first#define se second#define ZERO (x) memset ((x), 0, sizeof (x ) #define ALL (x) (x). Begin (), (x). End () #define REP (I, A, b) for (int i = (a); I <= (b); ++i) #define PER (I, a, b) for (in t i = (a); I >= (b); -I.) #define QUICKIO Ios::sync_with_stdio (FALSE); Cin.tie (0); Cout.tie (0); using namespace Std;int a,b,c;double dp[105][105][105];int main () {memset (dp,0,sizeof (DP)); cin>>a>>b>>c; Dp[a][b][c]=1; Per (i,a,1) per (j,b,1) per (k,c,1) {double tmp=i*j+j*k+i*k; if (j-1>=0) dp[i][j-1][k]+=i*j/tmp*dp[i][j][k]; if (i-1>=0) dp[i-1][j][k]+=i*k/tmp*dp[i][j][k]; if (k-1>=0) dp[i][j][k-1]+=k*j/tmp*dp[i][j][K]; } double ansi=0, ansj=0, ansk=0; Rep (I,1,a) Rep (j,1,100) ansi+=dp[i][j][0]; Rep (I,1,b) Rep (j,1,100) ansj+=dp[0][i][j]; Rep (I,1,c) Rep (j,1,100) ansk+=dp[j][0][i]; Cout<<fixed<<setprecision <<ansi<< "<<ansj<<" <<ansk<<endl; return 0;}
Daily training "bad Luck Island (codeforces Round 301 Div.2 D)