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. Git配置代理命令

    针对***的代理配置 设置代理 git config --global http.proxy 'socks5://127.0.0.1:1080' git config --global https.p ...

  2. 实现基于dotnetcore的扫一扫登录功能

    第一次写博客,前几天看到.netcore的认证,就心血来潮想实现一下基于netcore的一个扫一扫的功能,实现思路构思大概是web端通过cookie认证进行授权,手机端通过jwt授权,web端登录界面 ...

  3. java 学习第三篇if判断

    JAVA 判断 单词: if 如果 else 否则 单分支: If(条件) { 代码块 } If是一个判断语句.代码格式如上. If括号的内是表达式.如果表达式值是成立的便执行代码块.之后在执行IF语 ...

  4. 我的iphone不能被虚拟机识别怎么办

    我的iphone不能被虚拟机识别怎么办 听语音 | 浏览:3890 | 更新:2015-11-04 15:28 | 标签:iphone vmware ios 1 2 3 4 5 6 分步阅读 特大喜讯 ...

  5. AB二进制

    Description 若将一个正整数化为二进制数,在此二进制数中,我们将数字1的个数多于数字0的个数的这类二进制数称为A类数,否则就称其为B类数. 例如: (13)10=(1101)2        ...

  6. completer自动完成

    由于项目需要,在输入框中要做一些输入限制的同时,更加要求用户体验,提供一些自动完成设置.所以有需求,总会有解决方式,下面说一下自动完成插件的原理: html的body部分: <span styl ...

  7. 【规律】Gym 100739L Many recursions

    给出a,求递归式g(k)的初始条件g(0); 可以看出来g(a) = 1,从后往前推.写个模拟程序可以看出来其实g(0) = 2^a,那么就是一个简单地快速幂取模问题了. #include <c ...

  8. #6432. 「PKUSC2018」真实排名(组合数学)

    题面 传送门 题解 这数据范围--这输出大小--这模数--太有迷惑性了-- 首先对于\(0\)来说,不管怎么选它们的排名都不会变,这个先特判掉 对于一个\(a_i\)来说,如果它不选,那么所有大于等于 ...

  9. CF580D Kefa and Dishes 状压dp

    When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. Th ...

  10. Java基础笔记(十七)——继承(续)final

    final  最终的 修饰类,此类不能被继承.final与访问修饰符public位置随意,在class前即可.public final class A{ } 修饰方法,此方法不能被子类重写,但可以被子 ...