题解 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 ...
随机推荐
- 如何把activity当成dialog
在工作中有时候需要把activity当成dialog使用,其实做法挺简单的. 1.设置activity的style <style name="DialogTheme" par ...
- 性能测试 基于Python结合InfluxDB及Grafana图表实时采集Linux多主机性能数据
基于Python结合InfluxDB及Grafana图表实时采集Linux多主机性能数据 by:授客 QQ:1033553122 实现功能 测试环境 环境搭建 使用前提 使用方法 运行程序 效果展 ...
- Android为TV端助力context转换类型
- Android为TV端助力 播放视频卡顿问题
问题分析: 1.连接服务器,ping IP 看看有没有丢包 2.写一个只有mediaplayer的Demo,放到同款的盒子或者电视,保证网咯也是一样的情况下,看看Demo卡不卡 如果一直不卡,那有可能 ...
- centos7个人shell编写环境
一.配置存放文件/root/wang 存放常用的文件/root/wang/shell 存放练习的shell文件/root/wang/succeed_shell 存放有用shell文件/root/bak ...
- 使用C++对物理网卡/虚拟网卡进行识别(包含内外网筛选)
简介 在Socket编程的时候,我们需要实时获取我们所需要的IP地址.例如在编写后门的时候,我们可能需要获得有效的外网IP或内网IP:有时候我们可能需要判断我们获取的是否是虚拟机网卡,这时候就需要对每 ...
- 7 Best Free RAR Password Unlocker Software For Windows
Here is the list of Best Free RAR Password Unlocker Software for Windows. These software run differe ...
- Python简单的多线程demo:装逼写法
用面向对象来写多线程: import threading class MyThread(threading.Thread): def __init__(self, n): super(MyThread ...
- String输出结果to thi
http://blog.csdn.net/itmyhome1990/article/details/9132929
- java多线程(死锁,lock接口,等待唤醒机制)
一.Lock接口 常用方法 Lock提供了一个更加面对对象的锁,在该锁中提供了更多的操作锁的功能. 使用Lock接口,以及其中的lock()方法和unlock()方法替代同步,对电影院卖票案例中Tic ...