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. 【Python学习】使用BeautifulSoup解析HTML

    对于一个最简单的爬虫结构的代码是这样的. 也就是抓取出整个页面,然后创建一个BeautifulSoup对象. from urllib.request import urlopen from bs4 i ...

  2. 【并行计算】用MPI进行分布式内存编程(二)

    通过上一篇中,知道了基本的MPI编写并行程序,最后的例子中,让使用0号进程做全局的求和的所有工作,而其他的进程却都不工作,这种方式也许是某种特定情况下的方案,但明显不是最好的方案.举个例子,如果我们让 ...

  3. angular项目中使用jQWidgets

    Angular CLI with jQWidgets In this tutorial, we will show you how to use https://cli.angular.io/ alo ...

  4. sort排序命令常见用法

    sort -n 按数字排序 [root@test88 ~]# cat test.txt 19036 6111 24039 3660 20610 10937 32408 20744 8248 28255 ...

  5. 你需要知道的Nginx配置二三事

    做服务端开发的,工作中难免会遇到处理Nginx配置相关问题.在配置Nginx时,我一直本着“照葫芦画瓢”的原则,复制已有的配置代码,自己修修改改然后完成配置需求,当有人问起Nginx相关问题时,其实仍 ...

  6. 对cgic的理解——name选项

    #include <stdio.h>#include <stdlib.h>#include <string.h>#include "cgic.h" ...

  7. 2018-2019-2 网络对抗技术 20165301 Exp6 信息搜集与漏洞扫描

    2018-2019-2 网络对抗技术 20165301 Exp6 信息搜集与漏洞扫描 1.实践目标 掌握信息搜集的最基础技能与常用工具的使用方法. 2.实践内容 (1)各种搜索技巧的应用 (2)DNS ...

  8. python基础(9)--递归、二叉算法、多维数组、正则表达式

    1.递归 在函数内部,可以调其他函数,如果一个函数在内部调用它本身,这个函数就是递归函数.递归算法对解决一大类问题是十分有效的,它往往使算法的描述简洁而且易于裂解 递归算法解决问题的特点: 1)递归是 ...

  9. bzoj 2819(DFS序+树状数组+博弈+lca)

    2819: Nim Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 2045  Solved: 795[Submit][Status][Discuss] ...

  10. jquery 获取某a标签的href地址 实现页面加载时跳转

    jQuery(document).ready(function(){if(jQuery("#zzjg a").length>0){var hrefValue = jQuery ...