【题目链接】

http://poj.org/problem?id=2096

【算法】

概率DP

【代码】

  1. #include <algorithm>
  2. #include <bitset>
  3. #include <cctype>
  4. #include <cerrno>
  5. #include <clocale>
  6. #include <cmath>
  7. #include <complex>
  8. #include <cstdio>
  9. #include <cstdlib>
  10. #include <cstring>
  11. #include <ctime>
  12. #include <deque>
  13. #include <exception>
  14. #include <fstream>
  15. #include <functional>
  16. #include <limits>
  17. #include <list>
  18. #include <map>
  19. #include <iomanip>
  20. #include <ios>
  21. #include <iosfwd>
  22. #include <iostream>
  23. #include <istream>
  24. #include <ostream>
  25. #include <queue>
  26. #include <set>
  27. #include <sstream>
  28. #include <stdexcept>
  29. #include <streambuf>
  30. #include <string>
  31. #include <utility>
  32. #include <vector>
  33. #include <cwchar>
  34. #include <cwctype>
  35. #include <stack>
  36. #include <limits.h>
  37. using namespace std;
  38. #define MAXN 1010
  39.  
  40. int i,j,n,s;
  41. double f[MAXN][MAXN];
  42.  
  43. int main()
  44. {
  45.  
  46. while (scanf("%d%d",&n,&s) != EOF)
  47. {
  48. memset(f,,sizeof(f));
  49. f[n][s] = ;
  50. for (i = n; i >= ; i--)
  51. {
  52. for (j = s; j >= ; j--)
  53. {
  54. if (i == n && j == s) continue;
  55. f[i][j] = (1.0 * i * (s - j) * f[i][j+] + 1.0 * (n - i) * j * f[i+][j] + 1.0 * (n - i) * (s - j) * f[i+][j+] + n * s) / (n * s - i * j);
  56. }
  57. }
  58. printf("%.4lf\n",f[][]);
  59. }
  60.  
  61. return ;
  62.  
  63. }

【POJ 2096】 Collecting Bugs的更多相关文章

  1. 【POJ 2096】Collecting Bugs 概率期望dp

    题意 有s个系统,n种bug,小明每天找出一个bug,可能是任意一个系统的,可能是任意一种bug,即是某一系统的bug概率是1/s,是某一种bug概率是1/n. 求他找到s个系统的bug,n种bug, ...

  2. 【POJ】【2096】Collecting Bugs

    概率DP/数学期望 kuangbin总结中的第二题 大概题意:有n个子系统,s种bug,每次找出一个bug,这个bug属于第 i 个子系统的概率为1/n,是第 j 种bug的概率是1/s,问在每个子系 ...

  3. 「 poj 2096 」 Collecting Bugs

    先说一下题意 $s$ 个子系统还中有 $n$ 种 $\text{bug}$,每天可以随机选择一种 $\text{bug}$,问选出 $n$ 种 $\text{bug}$ 在 $s$ 种子系统中的期望天 ...

  4. 【POJ2096】Collecting Bugs 期望

    [POJ2096]Collecting Bugs Description Ivan is fond of collecting. Unlike other people who collect pos ...

  5. bzoj 2295: 【POJ Challenge】我爱你啊

    2295: [POJ Challenge]我爱你啊 Time Limit: 1 Sec  Memory Limit: 128 MB Description ftiasch是个十分受女生欢迎的同学,所以 ...

  6. 【链表】BZOJ 2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 382  Solved: 111[Submit][S ...

  7. BZOJ2288: 【POJ Challenge】生日礼物

    2288: [POJ Challenge]生日礼物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 284  Solved: 82[Submit][St ...

  8. BZOJ2293: 【POJ Challenge】吉他英雄

    2293: [POJ Challenge]吉他英雄 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 80  Solved: 59[Submit][Stat ...

  9. BZOJ2287: 【POJ Challenge】消失之物

    2287: [POJ Challenge]消失之物 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 254  Solved: 140[Submit][S ...

随机推荐

  1. linux ssh 经常断开 的解决方法

    1.现象 在linux ,用ssh进行远程连接时,经常会发生长时间后断线,或者是无响应,就像卡住的感觉(键盘输入不进去). 2.解决方法 在ssh客户端的linux设置 # sudo vim /etc ...

  2. nodejs要远程连接另一个主机上的monogodb数据库服务器

    我的mongodb是装在linux下的. 首先,先添加用户 1.首先在mongodb服务器主机上进行terminal命令行,输入 mongo 2.输入 use admin 进入用户管理数据库 3.db ...

  3. ASP.NET Cache 实现依赖Oracle的缓存策略

    ASP.NET 中的缓存提供了对SQL依赖项的支持,也就是说当SQL SERVER数据库中的表或行中的数据被更改后,缓存中的页面就失效,否则,页面输出可一直保留在缓存当中.这确实为程序员提供了方便.但 ...

  4. C#异步Async、Task、Await

    参考http://www.cnblogs.com/jesse2013/p/async-and-await.html 事例: static void Main(string[] args) { ; i ...

  5. emlog通过pjax实现无刷新加载网页--完美解决cnzz统计和javascript失效问题

    想要更详细了解pjax,需要查看官网 或者看本站文章:jQuery.pjax.js:使用AJAX和pushState无刷新加载网页(官网教程中文翻译) 效果看本站,音乐无刷新播放,代码高亮和复制js加 ...

  6. 使用脚本卸载.net framework for mac

    官方只提供了安装包,没提供卸载

  7. node mysql es6/es7改造

    本文js代码采取了ES6/ES7的写法,而不是commonJs的写法.支持一波JS的新语法.node版本的mysql驱动,通过npm i mysql安装.官网地址:https://github.com ...

  8. Python【每日一问】35

    问: 基础题: 从键盘输入4个数字,各数字采用空格分隔,对应为变量x0,y0,x1,y1.计算(x0,y0)和(x1,y1)两点之间的距离,输出结果保留1位小数. 比如,键盘输入:0 1 3 5,屏幕 ...

  9. 洛谷P1443 马的遍历【BFS】

    题目描述 有一个n*m的棋盘(1<n,m<=400),在某个点上有一个马,要求你计算出马到达棋盘上任意一个点最少要走几步 输入输出格式 输入格式: 一行四个数据,棋盘的大小和马的坐标 输出 ...

  10. 调用的方法里接收一个List<>类型的参数,里面是自定义的EC类, 我要通过反射构建这List对象

              public static object CreateGeneric(Type generic, Type innerType, params object[] args)     ...