Bad Luck Island
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 rs 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 test(s)
input
2 2 2
output
0.333333333333 0.333333333333 0.333333333333
input
2 1 2
output
0.150000000000 0.300000000000 0.550000000000
input
1 1 3
output
0.057142857143 0.657142857143 0.285714285714

题目大意:在玩猜拳游戏,只会出石头的r个人,只会出剪刀的s个人,只会出布的p个人。三类人中最后会剩下一种人的概率分别是多少。
定义dp[i][j][k]表示剩下出石头的i个,出剪刀的j个,出布的k个的概率。dp[i][j][k]=dp[i+1][j][k]*pi+dp[i][j+1][k]*pj+dp[i][j][k+1]*pk。
#include<bits/stdc++.h>
using namespace std;
double dp[110][110][110];
int main(){
int r,s,p;
double sum;
while(scanf("%d%d%d",&r,&s,&p)!=EOF){
memset(dp,0,sizeof(dp));
dp[r][s][p]=1.0;
for(int i=r;i>=1;i--){
for(int j=s;j>=1;j--){
for(int k=p;k>=1;k--){
sum=i*j+j*k+i*k*1.0;
dp[i-1][j][k]+=dp[i][j][k]*(i*k*1.0/sum);
dp[i][j-1][k]+=dp[i][j][k]*(i*j*1.0/sum);
dp[i][j][k-1]+=dp[i][j][k]*(j*k*1.0/sum);
}
}
}
double ans1,ans2,ans3;
ans1=ans2=ans3=0;
for(int i=r;i>=1;i--){
for(int j=s;j>=0;j--){
ans1+=dp[i][j][0];
}
}
for(int j=s;j>=1;j--){
for(int k=p;k>=0;k--){
ans2+=dp[0][j][k];
}
}
for(int i=r;i>=0;i--){
for(int k=p;k>=1;k--){
ans3+=dp[i][0][k];
}
}
printf("%.10f %.10f %.10f\n",ans1,ans2,ans3);
}
return 0;
}

  

CF 540D——Bad Luck Island——————【概率dp】的更多相关文章

  1. codeforces 540D Bad Luck Island (概率DP)

    题意:会出石头.剪刀.布的人分别有r,s,p个,他们相互碰到的概率相同,输的人死掉,问最终活下去的人是三种类型的概率 设状态dp(i,j,k)为还有i个石头,j个剪刀,k个布时的概率,dp(r,s,p ...

  2. Codeforces Round #301 (Div. 2) D. Bad Luck Island 概率DP

    D. Bad Luck Island Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/540/pr ...

  3. Codeforces 540D Bad Luck Island - 概率+记忆化搜索

    [题意] 一个岛上有三种生物A,B,C,各有多少只在输入中会告诉你,每种最多100只 A与B碰面,A会吃掉B, B与C碰面,B会吃掉C, C与A碰面,C会吃掉A...忍不住想吐槽这种环形食物链 碰面是 ...

  4. CF 540D Bad Luck Island

    一看就是DP题(很水的一道紫题) 设\(dp[i][j][k]\)为留下\(i\)个\(r\)族的人,死去\(j\)个\(s\)族的人,死去\(k\)个\(p\)族的人的概率(跟其他的题解有点差别,但 ...

  5. cf540D. Bad Luck Island(概率dp)

    题意 岛上有三个物种:剪刀$s$.石头$r$.布$p$ 其中剪刀能干掉布,布能干掉石头,石头能干掉剪刀 每天会从这三个物种中发生一场战争(也就是说其中的一个会被干掉) 问最后仅有$s/r/p$物种生存 ...

  6. CodeForces - 540D Bad Luck Island —— 求概率

    题目链接:https://vjudge.net/contest/226823#problem/D The Bad Luck Island is inhabited by three kinds of ...

  7. CodeForces 540D Bad Luck Island (DP)

    题意:一个岛上有石头,剪刀和布,规则就不用说了,问你最后只剩下每一种的概率是多少. 析:很明显的一个概率DP,用d[i][j][k]表示,石头剩下 i 个,剪刀剩下 j 个,布剩下 k 个,d[r][ ...

  8. 540D - Bad Luck Island(概率DP)

    原题链接:http://codeforces.com/problemset/problem/540/D 题意:给你石头.剪刀.布的数量,它们之间的石头能干掉剪刀,剪刀能干掉布,布能干掉石头,问最后石头 ...

  9. CF 148D Bag of mice 概率dp 难度:0

    D. Bag of mice time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

随机推荐

  1. HttpWebRequest,HttpWebResponse 使用

    目的:工作中已经两次使用了,特此记录一下,并写好注释 /// <summary> /// HttpWebRequest的基本配置 /// </summary> public c ...

  2. 更新XML的Attribute(属性)

    有一个XML文档,一个属性"pk"错了,正确是2.我们怎样把它更改正确?原XML文档如下: <?xml version="1.0" encoding=&q ...

  3. JavaScript(3)——Object-Oriented Design

    自己定义函数 var Winston = function(nickname, age, x, y) { this.nickname = nickname; this.age = age + &quo ...

  4. (原创)Codeforces Round #550 (Div. 3) A Diverse Strings

    A. Diverse Strings time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  5. loj #2025. 「JLOI / SHOI2016」方

    #2025. 「JLOI / SHOI2016」方   题目描述 上帝说,不要圆,要方,于是便有了这道题. 由于我们应该方,而且最好能够尽量方,所以上帝派我们来找正方形.上帝把我们派到了一个有 NNN ...

  6. 【洛谷2324】[SCOI2005]骑士精神 IDA*

    [SCOI2005]骑士精神 描述 在一个\(5×5\)的棋盘上有\(12\)个白色的骑士和\(12\)个黑色的骑士, 且有一个空位.在任何时候一个骑士都能按照骑 士的走法(它可以走到和它横坐标相差为 ...

  7. Java实现微信小程序支付(准备)

    Java语言开发微信小程序支付功能: 1.通过https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=11_1路径到官方下载Java的支付SD ...

  8. git 日常使用从入门到真香

    目录 git 日常使用从入门到真香 一.Git简介 二.Git常用命令 三.git操作流程 四.报错处理 git 日常使用从入门到真香 一.Git简介 Git是一个开源的分布式版本控制系统,可以有效. ...

  9. POJ2676 (数独问题 + DLX + 状态优化顺序)

    (1)最简单的最是去暴力DFS搜索答案 , 很容易想到 , 每行每列的方式去搜索 , 不过效率是真的不行;但这个还是给出代码 ,毕竟打了也不容易呀! #include<cstdio> #i ...

  10. jquery 拖动改变div大小

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...