Codeforces 540D Bad Luck Island
http://codeforces.com/problemset/problem/540/D
题目大意:
会出石头、剪刀、布的人分别有r,s,p个,他们相互碰到的概率相同,输的人死掉,问最终活下去的人是三种类型的概率。
思路:
f[i][j][k]代表i个石头,j个剪刀,k个布状态的概率,初始f[n][m][K]=1
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
#define dou long double
dou jc[];
dou f[][][];
int n,m,K;
int read(){
int t=,f=;char ch=getchar();
while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
while (''<=ch&&ch<=''){t=t*+ch-'';ch=getchar();}
return t*f;
}
int main(){
n=read();m=read();K=read();
f[n][m][K]=1.0;
for (int i=n;i>=;i--)
for (int j=m;j>=;j--)
for (int k=K;k>=;k--)
if (f[i][j][k]>)
{
int cnt=((int)(i==))+((int)(j==))+((int)(k==));
if (cnt>=) continue;
double tot=i*j+j*k+k*i;
if (i>)
f[i-][j][k]+=f[i][j][k]*(i*k)/tot;
if (j>)
f[i][j-][k]+=f[i][j][k]*(i*j)/tot;
if (k>)
f[i][j][k-]+=f[i][j][k]*(k*j)/tot;
}
double ans1=,ans2=,ans3=;
for (int i=;i<=n;i++)
ans1+=(double)f[i][][];
for (int i=;i<=m;i++)
ans2+=(double)f[][i][];
for (int i=;i<=K;i++)
ans3+=(double)f[][][i];
printf("%.9f %.9f %.9f\n",ans1,ans2,ans3);
return ;
}
Codeforces 540D Bad Luck Island的更多相关文章
- CodeForces - 540D Bad Luck Island —— 求概率
题目链接:https://vjudge.net/contest/226823#problem/D The Bad Luck Island is inhabited by three kinds of ...
- Codeforces 540D Bad Luck Island - 概率+记忆化搜索
[题意] 一个岛上有三种生物A,B,C,各有多少只在输入中会告诉你,每种最多100只 A与B碰面,A会吃掉B, B与C碰面,B会吃掉C, C与A碰面,C会吃掉A...忍不住想吐槽这种环形食物链 碰面是 ...
- CodeForces 540D Bad Luck Island (DP)
题意:一个岛上有石头,剪刀和布,规则就不用说了,问你最后只剩下每一种的概率是多少. 析:很明显的一个概率DP,用d[i][j][k]表示,石头剩下 i 个,剪刀剩下 j 个,布剩下 k 个,d[r][ ...
- codeforces 540D Bad Luck Island (概率DP)
题意:会出石头.剪刀.布的人分别有r,s,p个,他们相互碰到的概率相同,输的人死掉,问最终活下去的人是三种类型的概率 设状态dp(i,j,k)为还有i个石头,j个剪刀,k个布时的概率,dp(r,s,p ...
- CF 540D——Bad Luck Island——————【概率dp】
Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces B. Bad Luck Island(概率dp)
题目描述: Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 540D - Bad Luck Island(概率DP)
原题链接:http://codeforces.com/problemset/problem/540/D 题意:给你石头.剪刀.布的数量,它们之间的石头能干掉剪刀,剪刀能干掉布,布能干掉石头,问最后石头 ...
- CF 540D Bad Luck Island
一看就是DP题(很水的一道紫题) 设\(dp[i][j][k]\)为留下\(i\)个\(r\)族的人,死去\(j\)个\(s\)族的人,死去\(k\)个\(p\)族的人的概率(跟其他的题解有点差别,但 ...
- 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 ...
随机推荐
- 新博客——That
很久没写博客了,打算换个地方重新开始. 旧博客地址如下: http://blog.csdn.net/that163
- Apache-common项目提供的工具
---- MD5加密与生成UUID例子(依赖于commons-io.jar):begin ------------------------------------------------------- ...
- P - Atlantis - hdu1542(求面积)
题意:rt 求面积......不计算重复面积(废话..)hdu1255 的弱化版,应该先做这道题在做那道题的. ******************************************** ...
- Truncate Table 用法
TRUNCATE TABLE 删除表中的所有行,而不记录单个行删除操作. 语法 TRUNCATE TABLE name 参数 name 是要截断的表的名称或要删除其全部行的表的名称. 注释 TRUNC ...
- Delphi TStringList的用法
Delphi TStringList的用法 TStrings是一个抽象类,在实际开发中,是除了基本类型外,应用得最多的. TStringList 常用方法与属性: var List: TStringL ...
- Javascript:DOM表格操作
需求说明: /* *需求说明: *获取元素:tBodies,tHead,tFoot,rows,cells *表格的创建 *数据添加 *隔行变色 *删除操作,剩余表格重新计算,实现隔行变色 */ HTM ...
- Android两种 旋转Bitmap方法
方法1. 利用Bitmap.createBitmap Bitmap adjustPhotoRotation(Bitmap bm, final int orientationDegree) { ...
- 使用java连接AD域,验证账号password是否正确
web项目中有时候客户要求我们使用ad域进行身份确认,不再另外做一套用户管理系统.事实上客户就是仅仅要一套账号能够訪问全部的OA.CRM等办公系统. 这就是第三方验证.一般有AD域,Ldap,Radi ...
- [AngularJS] Using AngularJS's ngClass
.blue{ color: blue } .bold{ font-weight: bold; } .large{ font-size: 40px; } ngClass can accept an ar ...
- 关于ajax网络请求的封装
// 封装的ajax网络请求函数// obj 是一个对象function AJAX(obj){ //跨域请求 if (obj.dataType == "jsonp") ...