D. Bad Luck Island

Time Limit: 1 Sec  Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/540/problem/D

Description

The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors and p papers. At some moments of time two random individuals meet (all pairs of individuals can meet equiprobably), and if they belong to different species, then one individual kills the other one: a rock kills scissors, scissors kill paper, and paper kills a rock. Your task is to determine for each species what is the probability that this species will be the only one to inhabit this island after a long enough period of time.

Input

The single line contains three integers r, s and p (1 ≤ r, s, p ≤ 100) — the original number of individuals in the species of rock, scissors and paper, respectively.

Output

Print three space-separated real numbers: the probabilities, at which the rocks, the scissors and the paper will be the only surviving species, respectively. The answer will be considered correct if the relative or absolute error of each number doesn't exceed 10 - 9.

Sample Input

2 2 2

Sample Output

0.333333333333 0.333333333333 0.333333333333

HINT

题意

有个地方有三种人,分别是石头,剪刀,步

每天都会有俩不同种族的人出来,然互石头会杀死剪刀,剪刀会杀死步,步会干掉石头

然后问你,在最后,每个种族活到最后的概率是多少

题解:

概率dp,dp[i][j][k]表示,剩下人数为i,j,k的概率,转移方程:

double tmp=(i+j+k)*(i+j+k-)/-(i*(i-)/)-j*(j-)/-k*(k-)/;
//总共有多少种选择方法
if (j>&&i>)
dp[i][j-][k]+=dp[i][j][k]*i*j/tmp;
//选择石头剪刀的概率
if (j>&&k>)
dp[i][j][k-]+=dp[i][j][k]*j*k/tmp;
//选择剪刀布的概率
if (i>&&k>)
dp[i-][j][k]+=dp[i][j][k]*k*i/tmp;
//选择布和石头的概率

水DP = =

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
//const int inf=0x7fffffff; //§ß§é§à§é¨f§³
const int inf=0x3f3f3f3f;
/* inline void P(int x)
{
Num=0;if(!x){putchar('0');puts("");return;}
while(x>0)CH[++Num]=x%10,x/=10;
while(Num)putchar(CH[Num--]+48);
puts("");
}
*/
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** double dp[][][]; int main()
{
int r,s,p;
cin>>r>>s>>p;
dp[r][s][p]=;
double ans1=,ans2=,ans3=;
for(int i=r;i>=;i--)
{
for(int j=s;j>=;j--)
{
for(int k=p;k>=;k--)
{
double tmp=(i+j+k)*(i+j+k-)/-(i*(i-)/)-j*(j-)/-k*(k-)/;
if (j>&&i>)
dp[i][j-][k]+=dp[i][j][k]*i*j/tmp;
if (j>&&k>)
dp[i][j][k-]+=dp[i][j][k]*j*k/tmp;
if (i>&&k>)
dp[i-][j][k]+=dp[i][j][k]*k*i/tmp;
}
}
}
for(int i=r;i>=;i--)
ans1+=dp[i][][];
for(int j=s;j>=;j--)
ans2+=dp[][j][];
for(int k=p;k>=;k--)
ans3+=dp[][][k];
printf("%.10f %.10f %.10f\n",ans1,ans2,ans3);
}

Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率DP的更多相关文章

  1. Codeforces Round #105 (Div. 2) D. Bag of mice 概率dp

    题目链接: http://codeforces.com/problemset/problem/148/D D. Bag of mice time limit per test2 secondsmemo ...

  2. Codeforces Round #293 (Div. 2) D. Ilya and Escalator 概率DP

    D. Ilya and Escalator time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  3. Codeforces Round #284 (Div. 2) D. Name That Tune [概率dp]

    D. Name That Tune time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  4. Codeforces Round #233 (Div. 2)D. Painting The Wall 概率DP

                                                                                   D. Painting The Wall ...

  5. Codeforces Round #597 (Div. 2) E. Hyakugoku and Ladders 概率dp

    E. Hyakugoku and Ladders Hyakugoku has just retired from being the resident deity of the South Black ...

  6. DFS/BFS Codeforces Round #301 (Div. 2) C. Ice Cave

    题目传送门 /* 题意:告诉起点终点,踩一次, '.'变成'X',再踩一次,冰块破碎,问是否能使终点冰破碎 DFS:如题解所说,分三种情况:1. 如果两点重合,只要往外走一步再走回来就行了:2. 若两 ...

  7. 贪心 Codeforces Round #301 (Div. 2) B. School Marks

    题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...

  8. 贪心 Codeforces Round #301 (Div. 2) A. Combination Lock

    题目传送门 /* 贪心水题:累加到目标数字的距离,两头找取最小值 */ #include <cstdio> #include <iostream> #include <a ...

  9. CodeForces Round #301 Div.2

    今天唯一的成果就是把上次几个人一起开房打的那场cf补一下. A. Combination Lock 此等水题看一眼样例加上那个配图我就明白题意了,可是手抽没有注释掉freopen,WA了一发. #in ...

随机推荐

  1. Cesium 初始化Viewer

    <pre name="code" class="javascript"><script> var viewer = new Cesium ...

  2. flask插件系列之Flask-WTF表单

    flask_wtf是flask框架的表单验证模块,可以很方便生成表单,也可以当做json数据交互的验证工具,支持热插拔. 安装 pip install Flask-WTF Flask-WTF其实是对w ...

  3. [004] last_k_node

    [Description] find the k-th node from the last node of single linked list. e.g. Linked-list: 1-2-3-4 ...

  4. numpy 简介

    .caret, .dropup > .btn > .caret { border-top-color: #000 !important; } .label { border: 1px so ...

  5. Python下urllib2应用

    #coding=utf-8 import urllib,urllib2 url = 'http://www.xxx.com' values = {'wd' : 'python', 'language' ...

  6. mongodb与mysql传统的关系数据库区别

    转自:易百教程 MongoDB中的数据具有灵活的模式.文档在同一集合,但它们不需要具有相同的字段或结构集合,集合文档中的公共字段可以包含不同类型的数据. MongoDB中的数据具有灵活的模式.与SQL ...

  7. HEVC代码记录(删除)

    得到编码残差  TEncSearch.cpp 4543:rpcYuvResi->subtract( pcYuvOrg, pcYuvPred, 0, uiWidth );

  8. Linux 基础——权限管理命令chown、chgrp

    一.chown命令与chgrp命令的作用 有时你需要改变文件或目录的属主,比如有人离职或开发人员创建了一个在测试或生产环境中需要归属在系统账户下的应用.Linux提供了两个命令来实现这个功能:chow ...

  9. wxPython 画图板

    终于开始Python学习之旅了,姑且以一个“画图板”小项目开始吧.放慢脚步,一点一点地学习. 1月28日更新 第一次遇到的麻烦便是“重绘”,查了好多资料,终于重绘成功了. #-*- encoding: ...

  10. 取消cp确认

    使用cp -r -f 强制覆盖拷贝命令时,每一个文件都需要认为的键入“Y”进行确认 可以通过取消同名cp的定义,命令如下unalias cp