【POJ】2096 Collecting Bugs(数学期望)
题目
传送门:QWQ
分析
数学期望
用$ dp[i][j] $表示发现了在$ j $个子系统里面发现了$ i $个bug到$ s $个子系统里面发现了$ n $个bug需要的期望天数。
$ dp[0][0] $就是答案。
然后分类一下,可以转移到$ dp[i][j] $无非就是$ dp[i+1][j+1] $ $ dp[i][j+1] $ $ dp[i+1][j] $ $ dp[i][j] $
各自分别算一下概率,比如从$ dp[i][j] $转移过来的话概率是$ \frac{i}{n} \times \frac{j}{s} $因为这天要刚好落在已经选择过的$ i $个bug和$ j $个子系统里。
其他的也差不多。
代码
由于日常include <bits/stdc++.h>所以poj的ce数量超级多。。。。。
// #include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=;
double dp[maxn][maxn];
int main(){
double n,s; scanf("%lf%lf",&n,&s);
memset(dp,,sizeof(dp));
for(int i=n;i>=;i--)
for(int j=s;j>=;j--){
if(i==n&&j==s) continue;
double p1=i*j/n/s,p2=i*(s-j)/n/s,p3=(s-j)*(n-i)/n/s,p4=(n-i)*j/n/s;
dp[i][j]=(+p2*dp[i][j+]+p3*dp[i+][j+]+p4*dp[i+][j])/(-p1);
}
printf("%.5f\n",dp[][]);
return ;
}
【POJ】2096 Collecting Bugs(数学期望)的更多相关文章
- poj 2096 Collecting Bugs(期望 dp 概率 推导 分类讨论)
Description Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other ...
- POJ 2096 Collecting Bugs:期望dp
题目链接:http://poj.org/problem?id=2096 题意: 有一个程序猿,他每天都会发现一个bug. bug共有n个种类.属于某一个种类的概率为1/n. 有s个子系统,每个bug属 ...
- POJ 2096 Collecting Bugs 期望dp
题目链接: http://poj.org/problem?id=2096 Collecting Bugs Time Limit: 10000MSMemory Limit: 64000K 问题描述 Iv ...
- POJ 2096 Collecting Bugs (概率DP,求期望)
Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...
- poj 2096 Collecting Bugs (概率dp 天数期望)
题目链接 题意: 一个人受雇于某公司要找出某个软件的bugs和subcomponents,这个软件一共有n个bugs和s个subcomponents,每次他都能同时随机发现1个bug和1个subcom ...
- poj 2096 Collecting Bugs && ZOJ 3329 One Person Game && hdu 4035 Maze——期望DP
poj 2096 题目:http://poj.org/problem?id=2096 f[ i ][ j ] 表示收集了 i 个 n 的那个. j 个 s 的那个的期望步数. #include< ...
- Poj 2096 Collecting Bugs (概率DP求期望)
C - Collecting Bugs Time Limit:10000MS Memory Limit:64000KB 64bit IO Format:%I64d & %I64 ...
- poj 2096 Collecting Bugs 【概率DP】【逆向递推求期望】
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 3523 Accepted: 1740 ...
- POJ 2096 Collecting Bugs
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 1716 Accepted: 783 C ...
- poj 2096 Collecting Bugs 概率dp 入门经典 难度:1
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 2745 Accepted: 1345 ...
随机推荐
- linux find/grep 与cat联合使用
find ./ -name file_name.txt | xargs cat >> file_name.txt
- nohup 不生成 nohup.out的方法
nohup java -jar /xxx/xxx/xxx.jar >/dev/>& & 关键在于最后的 >/dev/>& 部分,/dev/null是一个 ...
- 物理内存不够用,临时增大Linux交换分区的方法
当系统的物理内存不够用的时候,就需要将物理内存中的一部分空间释放出来,以供当前运行的程序使用.那些被释放的空间可能来自一些很长时间没有什么 操作的程序,这些被释放的空间被临时保存到Swap空间中,等到 ...
- Git观察和比较
log git log 时间是从下到上,从远到近 whatchanged git whatchanged 时间是从下到上,从远到近 diff --staged 比较工作区和缓存区之间的差异 g ...
- delphi7完全关闭一个窗体
如果一个工程中有若干个form,在程序运行中若要彻底关闭其中的一个窗体 除了点击右上角的小叉叉外,也可以在form的close事件中添加一句话 procedure TLockScreen.FormCl ...
- windows安装mysql方法 mysql5.7以后的安装方法
mysql 安装步骤: 1.www.mysql.com 下载mysql 2.解压mysql到E盘,或者其他盘解压后 E:\mysql\bin (bin一定要按照这个目录) 3.这bin目录 ...
- Java——抽象类、接口
body, table{font-family: 微软雅黑; font-size: 10pt} table{border-collapse: collapse; border: solid gray; ...
- 别名的使用注意,""真坑。
我们使用别名都是使用as关键字. 大多数时候我们都会省略as关键字,然后后面直接加别名就好了.我的习惯是别名用双引号括起来. 今天因为这个习惯坑了我一大波 首先oracle的别名的规则: AS 别名 ...
- 【python】venv使用
virtualenvwrapper 比 virualenv 好用一些. 准备 export WORKON_HOME=~/venv source /usr/bin/virtualenvwrapper.s ...
- tornado框架的get方法传递参数
tornado框架的get方法传递参数,代码: # encoding: utf-8 """ @version: ?? @author: andu99 @contact: ...