「日常訓練」Bad Luck Island(Codeforces Round 301 Div.2 D)
阿新 • • 發佈:2018-09-30
set ++ first ios sin rep names ble tor
題意與分析(CodeForces 540D)
代碼
#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 (int 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(10)<<ansi<<" "<<ansj<<" "<<ansk<<endl; return 0; }
「日常訓練」Bad Luck Island(Codeforces Round 301 Div.2 D)