题解 CF540D 【Bad Luck Island】
既然没有大佬写题解那本蒟蒻就厚颜无耻地写(水)一(经)下(验)吧
题目要求算出个种人单独留下的存活率
因为n,m,p的范围极小,
那么就可以方便地设3位dp状态dp[i][j][k]表示剩余i个石头,j个剪刀,k个布的概率
当前的相遇的总情况数为ij+ik+j*k
如果遇到的两个相同的人不发生变化转移可可以忽略
如果遇到不同的人 各自的情况分别为ij,ik,j*k
转移方以石头剪刀相遇为例转移方程就为ijdp[i][j-1][k] += (ij)/(ij+ik+jk)dp[i][j][k]
最后算出各自在其他人为0时自己从1到最大的概率累加起来
输出即可
代码
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define C getchar()-48
inline ll read()
{
ll s=,r=;
char c=C;
for(;c<||c>;c=C) if(c==-) r=-;
for(;c>=&&c<=;c=C) s=(s<<)+(s<<)+c;
return s*r;
}
const int N=1e2+;
int n,m,p;
double dp[N][N][N];
int main()
{
n=read(),m=read(),p=read();
dp[n][m][p]=1.0;
for(int i=n;i>=;i--)
for(int j=m;j>=;j--)
for(int o=p;o>=;o--)
{
if(i&&j) dp[i][j-][o]+=(1.0*i*j/(i*j+j*o+i*o))*dp[i][j][o];
if(j&&o) dp[i][j][o-]+=(1.0*j*o/(i*j+j*o+i*o))*dp[i][j][o];
if(i&&o) dp[i-][j][o]+=(1.0*i*o/(i*j+j*o+i*o))*dp[i][j][o];
}
double ed1=,ed2=,ed3=;
for(int i=;i<=n;i++) ed1+=dp[i][][];
for(int j=;j<=m;j++) ed2+=dp[][j][];
for(int o=;o<=p;o++) ed3+=dp[][][o];
printf("%.10f %.10f %.10f\n",ed1,ed2,ed3);
return ;
}
题解 CF540D 【Bad Luck Island】的更多相关文章
- cf540D. Bad Luck Island(概率dp)
题意 岛上有三个物种:剪刀$s$.石头$r$.布$p$ 其中剪刀能干掉布,布能干掉石头,石头能干掉剪刀 每天会从这三个物种中发生一场战争(也就是说其中的一个会被干掉) 问最后仅有$s/r/p$物种生存 ...
- CF540D Bad Luck Island
嘟嘟嘟 看到数据范围很小,就可以暴力\(O(n ^ 3)\)dp啦. 我们令\(dp[i][j][k]\)表示这三种人分别剩\(i, j, k\)个的概率.然后枚举谁挂了就行. 这里的重点在于两个人相 ...
- CF540D Bad Luck Island(期望dp)
传送门 解题思路 比较容易的一道期望\(dp\),设\(f[i][j][k]\)表示石头\(i\)个,剪刀\(j\)个,步子\(l\)个.然后转移的时候用组合数算一下就好了. 代码 #include& ...
- 【CF540D】 D. Bad Luck Island (概率DP)
D. Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- 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 ...
- CodeForces - 540D Bad Luck Island —— 求概率
题目链接:https://vjudge.net/contest/226823#problem/D The Bad Luck Island is inhabited by three kinds of ...
- 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 ...
- CF#301 D:Bad Luck Island (概率dp)
D:Bad Luck Island 一个岛上有r个石头,s个剪子,p个布,他们之间随机挑出两个相遇,如果不是相同物种,就会有一个消失,分别求出最后这座岛上只剩下一个物种的概率. 我们用dp[i][j] ...
- 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 540 D Bad Luck Island
Discription The Bad Luck Island is inhabited by three kinds of species: r rocks, s scissors andp pap ...
随机推荐
- 前端js面向对象编程以及封装组件的思想
demo-richbase 用来演示怎么使用richbase来制作组件的例子 作为一名前端工程师,写组件的能力至关重要.虽然javascript经常被人嘲笑是个小玩具,但是在一代代大牛的前仆后继的努力 ...
- idea 模板注释设置
一.首先我们来设置IDEA中类的模板: 1.File-->settings-->Editor-->File and Code Templates-->Files 我们选择Cla ...
- Python爬虫之正则表达式(1)
廖雪峰正则表达式学习笔记 1:用\d可以匹配一个数字:用\w可以匹配一个字母或数字: '00\d' 可以匹配‘007’,但是无法匹配‘00A’; ‘\d\d\d’可以匹配‘010’: ‘\w\w\d’ ...
- Jenkins+VS项目持续集成
软件安装 安装包下载连接:https://jenkins.io/download/ 安装步奏:略 账户名:admin 密码:C:\Program Files (x86)\Jenkins\secrets ...
- pymsql模块
老师的博客地址:http://www.cnblogs.com/wupeiqi/articles/5713330.html 通过pymysql 模块可以通过朋友去操作mysql 数据库,首先的在pip上 ...
- JSP七大动作
- mybatis 错误
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.TooManyR ...
- IDEA+API && SPI
JAVA中API和SPI的区别:https://blog.csdn.net/quanaianzj/article/details/82500019
- SegNet 理解与文章结构
SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation 发表于2016年,作者 Vijay B ...
- 错误: after element list
SyntaxError: missing ] after element list note: [ opened at line 18, column 16 可能出现重复引用