「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

Posted samhx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)相关的知识,希望对你有一定的参考价值。

题意与分析(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)的主要内容,如果未能解决你的问题,请参考以下文章

CF 540D Bad Luck Island

CF 301div2 D. Bad Luck Island

Codeforces 540D Bad Luck Island

[Codeforces Round #301 (Div. 2) D]Bad Luck Island(概率Dp)

CF540D Bad Luck Island(期望dp)

CF540D Bad Luck Island