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 ...
随机推荐
- 五大P2P平台费用一览
我看版上谈P2P的挺多的,正好我也投了点P2P, 今天看到一个不错的图 欢迎版上朋友讨论 -- 不忧不惧
- HDU_2057——64位无符号16进制数的运算
Problem Description There must be many A + B problems in our HDOJ , now a new one is coming. Give yo ...
- Beanstalkd(ubuntu安装)
安装Beanstalkd # apt-get install beanstalkd Unubtu 开启beanstalkd的持久化选项 #vim /etc/default/beanstalkd 把S ...
- 【转】MVC5中的区域(Areas)
MVC本身提倡的就是关注点分离.但是当项目本身的业务逻辑足够复杂,如果所有的业务逻辑都写个Controller文件夹下面的时候,你会看到非常庞大的各种命名的Controller,这个时候区域的作用就非 ...
- 预处理、const与sizeof相关面试题
1.用预处理指令#define 声明一个常数,用以表明一年中有多少秒(忽略闰年问题) #define语法知识: (1) 不能以分号结束,括号的使用防止宏定义展开后的二义性. (2) 预处理器将为你计算 ...
- http缓存策略
http://foofish.net/blog/95/http-cache-policy
- WinXP 无线提示“区域中找不到无线网络”的一种可能原因!
貌似WinXP还是无限经典,我也一直还在用,不知道哪天才会放弃.这次遇见的问题,或许也有XP爱好者也遇得见,记下点文字备忘.----------------------- 单调的切割线 ------- ...
- Codeforces 486C Palindrome Transformation(贪心)
题目链接:Codeforces 486C Palindrome Transformation 题目大意:给定一个字符串,长度N.指针位置P,问说最少花多少步将字符串变成回文串. 解题思路:事实上仅仅要 ...
- J2EE (十) 简洁的JSTL、EL
简介 JSTL(JSP Standard Tag Library ,JSP标准标签库)是一个不断完善的开放源代码的JSP标签库. 由四个定制标记库(core.format.xml 和 sql)和一对通 ...
- apache ab工具对网站进行压力测试
Apache -- ab工具主要测试网站的(并发性能) 这个工具非常的强大. 基本语法 : cmd>ab.exe –n 请求总次数 -c 并发数 请求页面的url 进入到ab.ex ...