http://codeforces.com/problemset/problem/540/D

题目大意:

会出石头、剪刀、布的人分别有r,s,p个,他们相互碰到的概率相同,输的人死掉,问最终活下去的人是三种类型的概率。

思路:

f[i][j][k]代表i个石头,j个剪刀,k个布状态的概率,初始f[n][m][K]=1

  1. #include<cstdio>
  2. #include<cmath>
  3. #include<algorithm>
  4. #include<cstring>
  5. #include<iostream>
  6. #define dou long double
  7. dou jc[];
  8. dou f[][][];
  9. int n,m,K;
  10. int read(){
  11. int t=,f=;char ch=getchar();
  12. while (ch<''||ch>''){if (ch=='-') f=-;ch=getchar();}
  13. while (''<=ch&&ch<=''){t=t*+ch-'';ch=getchar();}
  14. return t*f;
  15. }
  16. int main(){
  17. n=read();m=read();K=read();
  18. f[n][m][K]=1.0;
  19. for (int i=n;i>=;i--)
  20. for (int j=m;j>=;j--)
  21. for (int k=K;k>=;k--)
  22. if (f[i][j][k]>)
  23. {
  24. int cnt=((int)(i==))+((int)(j==))+((int)(k==));
  25. if (cnt>=) continue;
  26. double tot=i*j+j*k+k*i;
  27. if (i>)
  28. f[i-][j][k]+=f[i][j][k]*(i*k)/tot;
  29. if (j>)
  30. f[i][j-][k]+=f[i][j][k]*(i*j)/tot;
  31. if (k>)
  32. f[i][j][k-]+=f[i][j][k]*(k*j)/tot;
  33. }
  34. double ans1=,ans2=,ans3=;
  35. for (int i=;i<=n;i++)
  36. ans1+=(double)f[i][][];
  37. for (int i=;i<=m;i++)
  38. ans2+=(double)f[][i][];
  39. for (int i=;i<=K;i++)
  40. ans3+=(double)f[][][i];
  41. printf("%.9f %.9f %.9f\n",ans1,ans2,ans3);
  42. return ;
  43. }

Codeforces 540D Bad Luck Island的更多相关文章

  1. CodeForces - 540D Bad Luck Island —— 求概率

    题目链接:https://vjudge.net/contest/226823#problem/D The Bad Luck Island is inhabited by three kinds of ...

  2. Codeforces 540D Bad Luck Island - 概率+记忆化搜索

    [题意] 一个岛上有三种生物A,B,C,各有多少只在输入中会告诉你,每种最多100只 A与B碰面,A会吃掉B, B与C碰面,B会吃掉C, C与A碰面,C会吃掉A...忍不住想吐槽这种环形食物链 碰面是 ...

  3. CodeForces 540D Bad Luck Island (DP)

    题意:一个岛上有石头,剪刀和布,规则就不用说了,问你最后只剩下每一种的概率是多少. 析:很明显的一个概率DP,用d[i][j][k]表示,石头剩下 i 个,剪刀剩下 j 个,布剩下 k 个,d[r][ ...

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

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

  5. CF 540D——Bad Luck Island——————【概率dp】

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

  6. Codeforces B. Bad Luck Island(概率dp)

    题目描述: Bad Luck Island time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  7. 540D - Bad Luck Island(概率DP)

    原题链接:http://codeforces.com/problemset/problem/540/D 题意:给你石头.剪刀.布的数量,它们之间的石头能干掉剪刀,剪刀能干掉布,布能干掉石头,问最后石头 ...

  8. CF 540D Bad Luck Island

    一看就是DP题(很水的一道紫题) 设\(dp[i][j][k]\)为留下\(i\)个\(r\)族的人,死去\(j\)个\(s\)族的人,死去\(k\)个\(p\)族的人的概率(跟其他的题解有点差别,但 ...

  9. 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 ...

随机推荐

  1. 五大P2P平台费用一览

    我看版上谈P2P的挺多的,正好我也投了点P2P, 今天看到一个不错的图 欢迎版上朋友讨论       -- 不忧不惧

  2. HDU_2057——64位无符号16进制数的运算

    Problem Description There must be many A + B problems in our HDOJ , now a new one is coming. Give yo ...

  3. Beanstalkd(ubuntu安装)

    安装Beanstalkd # apt-get install beanstalkd Unubtu 开启beanstalkd的持久化选项 #vim  /etc/default/beanstalkd 把S ...

  4. 【转】MVC5中的区域(Areas)

    MVC本身提倡的就是关注点分离.但是当项目本身的业务逻辑足够复杂,如果所有的业务逻辑都写个Controller文件夹下面的时候,你会看到非常庞大的各种命名的Controller,这个时候区域的作用就非 ...

  5. 预处理、const与sizeof相关面试题

    1.用预处理指令#define 声明一个常数,用以表明一年中有多少秒(忽略闰年问题) #define语法知识: (1) 不能以分号结束,括号的使用防止宏定义展开后的二义性. (2) 预处理器将为你计算 ...

  6. http缓存策略

    http://foofish.net/blog/95/http-cache-policy

  7. WinXP 无线提示“区域中找不到无线网络”的一种可能原因!

    貌似WinXP还是无限经典,我也一直还在用,不知道哪天才会放弃.这次遇见的问题,或许也有XP爱好者也遇得见,记下点文字备忘.----------------------- 单调的切割线 ------- ...

  8. Codeforces 486C Palindrome Transformation(贪心)

    题目链接:Codeforces 486C Palindrome Transformation 题目大意:给定一个字符串,长度N.指针位置P,问说最少花多少步将字符串变成回文串. 解题思路:事实上仅仅要 ...

  9. J2EE (十) 简洁的JSTL、EL

    简介 JSTL(JSP Standard Tag Library ,JSP标准标签库)是一个不断完善的开放源代码的JSP标签库. 由四个定制标记库(core.format.xml 和 sql)和一对通 ...

  10. apache ab工具对网站进行压力测试

    Apache -- ab工具主要测试网站的(并发性能) 这个工具非常的强大. 基本语法 :   cmd>ab.exe –n 请求总次数  -c 并发数 请求页面的url     进入到ab.ex ...