D. 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.

Examples
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个布,每一次两个人随机碰上,输的人死掉,问只剩下每一种的概率。

【分析】

  还是一样的配方。。

  f[i][j][k]表示没了i个石头,j个剪刀,k个布的情况下剩下。。。的概率。

  这个也是要移项一下的。

  三个都做一遍就好了。

  【一开始概率求错了,求概率的话做好是用组合数算方案吧不容易错。。

 #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define Maxn 110 double f[][Maxn][Maxn][Maxn]; double C(int x)
{
return 1.0*x*(x-)/;
} int main()
{
int r,s,p;
scanf("%d%d%d",&r,&s,&p);
for(int i=r;i>=;i--)//rocks
for(int j=s;j>=;j--)//scissors
for(int k=p;k>=;k--)//papers
{
int N=r+s+p-i-j-k;if(N==) continue;
double PI=1.0/C(N),PP=C(r-i)+C(s-j)+C(p-k),
R=1.0*(r-i),S=1.0*(s-j),P=1.0*(p-k); if(j==s&&k==p) f[][i][j][k]=,f[][i][j][k]=f[][i][j][k]=;
else if(i==r&&k==p) f[][i][j][k]=,f[][i][j][k]=f[][i][j][k]=;
else if(i==r&&j==s) f[][i][j][k]=,f[][i][j][k]=f[][i][j][k]=;
else
{
f[][i][j][k]=(R*S*PI*f[][i][j+][k]+R*P*PI*f[][i+][j][k]+S*P*PI*f[][i][j][k+])/(1.0-PP*PI);
f[][i][j][k]=(R*S*PI*f[][i][j+][k]+R*P*PI*f[][i+][j][k]+S*P*PI*f[][i][j][k+])/(1.0-PP*PI);
f[][i][j][k]=(R*S*PI*f[][i][j+][k]+R*P*PI*f[][i+][j][k]+S*P*PI*f[][i][j][k+])/(1.0-PP*PI);
}
}
printf("%.9lf %.9lf %.9lf\n",f[][][][],f[][][][],f[][][][]);
return ;
}

2017-04-21 21:28:51

【CF540D】 D. Bad Luck Island (概率DP)的更多相关文章

  1. 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 ...

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

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

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

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

  4. CF540D Bad Luck Island(期望dp)

    传送门 解题思路 比较容易的一道期望\(dp\),设\(f[i][j][k]\)表示石头\(i\)个,剪刀\(j\)个,步子\(l\)个.然后转移的时候用组合数算一下就好了. 代码 #include& ...

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

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

  6. 题解 CF540D 【Bad Luck Island】

    既然没有大佬写题解那本蒟蒻就厚颜无耻地写(水)一(经)下(验)吧 题目要求算出个种人单独留下的存活率 因为n,m,p的范围极小, 那么就可以方便地设3位dp状态dp[i][j][k]表示剩余i个石头, ...

  7. CF#301 D:Bad Luck Island (概率dp)

    D:Bad Luck Island 一个岛上有r个石头,s个剪子,p个布,他们之间随机挑出两个相遇,如果不是相同物种,就会有一个消失,分别求出最后这座岛上只剩下一个物种的概率. 我们用dp[i][j] ...

  8. CF 540D——Bad Luck Island——————【概率dp】

    Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  9. Codeforces B. Bad Luck Island(概率dp)

    题目描述: Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

随机推荐

  1. Entity Framework(EF的Model First方法)

    EntityFramework,是Microsoft的一款ORM(Object-Relation-Mapping)框架.同其它ORM(如,NHibernate,Hibernate)一样, 一是为了使开 ...

  2. JS设计模式——6.方法的链式调用

    什么是链式调用 这个很容易理解,例如: $(this).setStyle('color', 'red').show(); 分解链式调用 链式调用其实是两个部分: 1.操作对象(也就是被操作的DOM元素 ...

  3. C++ Primer 5th 第17章 标准库特殊设施

    C++新标准库提供了很多新功能,它们更加强大和易用. tuple类型 tuple是一种类似pair的模板,pair可以用来保存一对逻辑上有关联的元素对.但与pair不同的是,pair只能存储两个成员, ...

  4. Oracle和MySQL的高可用方案对比【转】

    关于Oracle和MySQL的高可用方案,其实一直想要总结了,就会分为几个系列来简单说说.通过这样的对比,会对两种数据库架构设计上的细节差异有一个基本的认识.Oracle有一套很成熟的解决方案.用我在 ...

  5. java基础52 编码与解码

    1.解码与编码的含义 编码:把看得懂的字符变成看不懂的码值,这个过程就叫编码    解码:根据码值查到相对应的字符,我们把这个过程就叫解码 注意:编码与解码时,我们一般使用统一的码表,否则非常容易出现 ...

  6. 简单ORACLE分区表、分区索引

    前一段听说CSDN.COM里面很多好东西,同事建议看看合适自己也可以写一写,呵呵,今天第一次开通博客,随便写点东西,就以第一印象分区表简单写第一个吧. ORACLE对于分区表方式其实就是将表分段存储, ...

  7. inherited 的研究。

    结论: 1. inherited默认调用的是父类的同名 同参数方法.(常用,如果是同名 同参数方法 比如 overide 的,可以省略,只写个inherited就可.) 2. 子类的方法里可以 inh ...

  8. CxGrid 表格列内容居中

    首先每一列 Cxgrid 都不知道要当成什么来出来,所以每一列都有个properties 让你来设置,告诉cxgrid 这列的内容是什么,然后根据你给出的内容 再来决定用什么居中方式: 就是说 官方再 ...

  9. Unix IPC之Posix信号量实现生产者消费者

    采用多生产者,多消费者模型. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 /**  * 生产者  */ P(nempty); P(mutex); // 写入一个 ...

  10. MySQL学习笔记:从一个表update到另外一个表

    # ---- 测试数据 ---- # 表1 CREATE TABLE temp_x AS AS c_id, 1.11 AS c_amount FROM DUAL UNION ALL AS c_id, ...