传送门

##解题思路
  比较容易的一道期望$dp$,设$f[i][j][k]$表示石头$i$个,剪刀$j$个,步子$l$个。然后转移的时候用组合数算一下就好了。

##代码

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath> using namespace std;
const int MAXN = 105; int r,s,p;
double f[MAXN][MAXN][MAXN],ans1,ans2,ans3; inline int calc(int x,int y,int z){
return max(((x+y+z)*(x+y+z-1)-x*(x-1)-y*(y-1)-z*(z-1))/2,1);
} int main(){
scanf("%d%d%d",&r,&s,&p);
f[r][s][p]=1.0;
for(int i=r;i>=0;i--)
for(int j=s;j>=0;j--)
for(int l=p;l>=0;l--){
if(i==0 && j==0 && l==0) continue;
if(i==r && j==s && l==p) continue;
// cout<<i<<" "<<j<<" "<<l<<" "<<calc(i,j,l)<<endl;
f[i][j][l]+=f[i+1][j][l]*((double)((i+1)*l)/calc(i+1,j,l));
f[i][j][l]+=f[i][j+1][l]*((double)((j+1)*i)/calc(i,j+1,l));
f[i][j][l]+=f[i][j][l+1]*((double)((l+1)*j)/calc(i,j,l+1));
}
for(int i=1;i<=r;i++) ans1+=f[i][0][0];
for(int i=1;i<=s;i++) ans2+=f[0][i][0];
for(int i=1;i<=p;i++) ans3+=f[0][0][i];
printf("%.12lf %.12lf %.12lf",ans1,ans2,ans3);
return 0;
}

CF540D Bad Luck Island(期望dp)的更多相关文章

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

    题意 岛上有三个物种:剪刀$s$.石头$r$.布$p$ 其中剪刀能干掉布,布能干掉石头,石头能干掉剪刀 每天会从这三个物种中发生一场战争(也就是说其中的一个会被干掉) 问最后仅有$s/r/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. CF540D Bad Luck Island

    嘟嘟嘟 看到数据范围很小,就可以暴力\(O(n ^ 3)\)dp啦. 我们令\(dp[i][j][k]\)表示这三种人分别剩\(i, j, k\)个的概率.然后枚举谁挂了就行. 这里的重点在于两个人相 ...

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

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

  5. 【CF540D】 D. Bad Luck Island (概率DP)

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

  6. cf.301.D. Bad Luck Island(dp + probabilities)

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

  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. mongoose 常用数据库操作 更新

    更新 Model.update(conditions, update, [options], [callback]) db.js var mongoose = require('mongoose'); ...

  2. vue 使用Animate.css库

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. 有穷自动机(NFA、DFA)&正规文法&正规式之间的相互转化构造方法

    在编译原理(第三版清华大学出版社出版)中第三章的词法分析中,3.4.3.5.3.6小节中分别讲解了 1.什么是NFA(不确定的有穷自动机)和DFA(确定的有穷自动机) 2.如何将  不确定的有穷自动机 ...

  4. snaker配置

    1,导入jar包 jar包 2,snaker的配置 3,snaker的工具类 以上是使用snaker的最基本的配置. http://lightfor.org/snaker/demo.html

  5. 学习Caffe(一)安装Caffe

    Caffe是一个深度学习框架,本文讲阐述如何在linux下安装GPU加速的caffe. 系统配置是: OS: Ubuntu14.04 CPU: i5-4690 GPU: GTX960 RAM: 8G ...

  6. MySql命令行无法显示中文

    好烦遇到了,遇到MySql命令行无法显示中文问题????? show variables like 'char%';//显示字符集 set names utf8;//设置字符集 describer t ...

  7. CSS:CSS 图像拼合技术

    ylbtech-CSS:CSS 图像拼合技术 1.返回顶部 1. CSS 图像拼合技术 图像拼合 图像拼合就是单个图像的集合. 有许多图像的网页可能需要很长的时间来加载和生成多个服务器的请求. 使用图 ...

  8. Dynamic partition strict mode requires at least one static partition column.

    https://blog.csdn.net/huobumingbai1234/article/details/81099856

  9. ArcGIS version not specified.

    问题 在调用arcgis10 的ISurface用来取指定航线的地形时,这段代码在加载.dem时总是出错. 报: Fail to open raster dataset 解决方法: 在窗体中加载Map ...

  10. dp思维

    题目传输门 题意:有n个房间,m个诅咒,每个房间有一个数值,刚开始有一个初始值,每次进入一个房间可以选择消除诅咒或者不消除,消除诅咒只能顺序消除,消除诅咒就是拿初始值和房间的数值做运算,求最后最大的数 ...