【题目链接】

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

【算法】

概率DP

【代码】

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std;
#define MAXN 1010 int i,j,n,s;
double f[MAXN][MAXN]; int main()
{ while (scanf("%d%d",&n,&s) != EOF)
{
memset(f,,sizeof(f));
f[n][s] = ;
for (i = n; i >= ; i--)
{
for (j = s; j >= ; j--)
{
if (i == n && j == s) continue;
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);
}
}
printf("%.4lf\n",f[][]);
} return ; }

【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. 前端性能优化---DOM操作

    小结 1缓存DOM对象 场景:缓存DOM对象的方式也经常被用在元素的查找中,查找元素应该是DOM操作中最频繁的操作了,其效率优化也是大头.在一般情况下,我们会根据需要,将一些频繁被查找的元素缓存起来, ...

  2. Tour UVA - 1347

    John Doe, a skilled pilot, enjoys traveling. While on vacation, he rents a small plane and starts vi ...

  3. Android截图截取弹框AlertDialog

    1:效果如图 2:权限 <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" ...

  4. Android开发笔记(13)——ListFragment

    转载请注明:http://www.cnblogs.com/igoslly/p/6959108.html ListFragment ListFragment是继承于Fragment的类,专门用于包含Li ...

  5. 揭开jQuery的面纱-jQuery选择器简介(二)

    选择器并没有一个固定的定义,在某种程度上说,jQuery的选择器和样式表中的选择器十分相似.选择器具有如下特点: 1.简化代码的编写 2.隐式迭代 3.无须判断对象是否存在 “$”是选择器不可缺少的部 ...

  6. lvs直接路由模式DR模式

    1)实验所有关闭防火墙systemtcl stop firewalldsystemctl disable firewalldsetenforce 0iptables -F2)配置负载调度器配置虚拟IP ...

  7. kvm迁移

    一.迁移简介 迁移:      系统的迁移是指把源主机上的操作系统和应用程序移动到目的主机,并且能够在目的主机上正常运行.在没有虚拟机的时代,物理机之间的迁移依靠的是系统备份和恢复技术.在源主机上实时 ...

  8. Linux—Ubuntu14.0.5安装Redis

    1.前言 Redis是常用基于内存的Key-Value数据库,比Memcache更先进,支持多种数据结构,高效,快速.用Redis可以很轻松解决高并发的数据访问问题:做为时时监控信号处理也非常不错. ...

  9. 2.Eclipse中绑定Tomcat

    1.下载并成功安装Eclipse和Tomcat(该步骤有问题请查看我的相关经验): 2.打开Eclipse,单击“window”菜单,选择下方的“Preferences”: 3.找到Server下方的 ...

  10. VC2010常见问题的解决方案

    vc++里面的obj文件是什么文件Project(项目)中每个cpp经编译成为obj(object)目标文件,所有obj文件和资源文件经链接(link)成为可执行文件,obj文件可称为目标文件或中间文 ...