题目

传送门: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(数学期望)的更多相关文章

  1. poj 2096 Collecting Bugs(期望 dp 概率 推导 分类讨论)

    Description Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other ...

  2. POJ 2096 Collecting Bugs:期望dp

    题目链接:http://poj.org/problem?id=2096 题意: 有一个程序猿,他每天都会发现一个bug. bug共有n个种类.属于某一个种类的概率为1/n. 有s个子系统,每个bug属 ...

  3. POJ 2096 Collecting Bugs 期望dp

    题目链接: http://poj.org/problem?id=2096 Collecting Bugs Time Limit: 10000MSMemory Limit: 64000K 问题描述 Iv ...

  4. POJ 2096 Collecting Bugs (概率DP,求期望)

    Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other material stu ...

  5. poj 2096 Collecting Bugs (概率dp 天数期望)

    题目链接 题意: 一个人受雇于某公司要找出某个软件的bugs和subcomponents,这个软件一共有n个bugs和s个subcomponents,每次他都能同时随机发现1个bug和1个subcom ...

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

  7. Poj 2096 Collecting Bugs (概率DP求期望)

    C - Collecting Bugs Time Limit:10000MS     Memory Limit:64000KB     64bit IO Format:%I64d & %I64 ...

  8. poj 2096 Collecting Bugs 【概率DP】【逆向递推求期望】

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 3523   Accepted: 1740 ...

  9. POJ 2096 Collecting Bugs

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 1716   Accepted: 783 C ...

  10. poj 2096 Collecting Bugs 概率dp 入门经典 难度:1

    Collecting Bugs Time Limit: 10000MS   Memory Limit: 64000K Total Submissions: 2745   Accepted: 1345 ...

随机推荐

  1. shell 判断字符串长度是否为0

    test.sh #!/bin/bash echo "enter the string:" read filename if test -z $filename ; then ech ...

  2. python 去除字符串两端的引号

    a='"srting"' print(a) b=eval(a) print(b) 输出 "srting" srting

  3. Python 实现图片上表格的写入

    直接上代码:import matplotlib.pylab as pltimport numpy as npplt.figure()axes=plt.gca()y= np.random.randn(9 ...

  4. bzoj 3730 震波 (动态点分治)

    大意: 给定n节点树, 每个节点有权值, 边权全为1. 给定m个操作: 操作1: (0,x,k) 表示询问到节点x距离不超过k的节点权值和 操作2: (1,x,y) 表示将节点x的权值修改为y 对于所 ...

  5. Codeforces Round #415 (Div. 2)C

    反正又是一个半小时没做出来... 先排序,然后求和,第i个和第j个,f(a)=a[j]-a[i]=a[i]*(2^(j-i-1))因为从j到i之间有j-i-1个数(存在或者不存在有两种情况) 又有a[ ...

  6. OSI七层与tcp/ip四层

    1)OSI七层模型 OSI中的层 功能 TCP/IP协议族 应用层 文件传输,电子邮件,文件服务,虚拟终端 TFTP,HTTP,SNMP,FTP,SMTP,DNS,Telnet 表示层 数据格式化,代 ...

  7. 002PHP文件处理——文件处理 is_dir mkdir getcwd chdir rmdir

    <?php /** * 66 文件处理 is_dir mkdir getcwd chdir rmdir */ //is_dir() 判断一个目录是否存在 //var_dump(is_dir('6 ...

  8. Alpha阶段第1周 Scrum立会报告+燃尽图 06

    作业要求与https://edu.cnblogs.com/campus/nenu/2018fall/homework/2246相同 一.小组介绍 组长:刘莹莹 组员:朱珅莹 孙韦男 祝玮琦 王玉潘 周 ...

  9. LARC Caffe笔记(一) Setup

    采用杂记的形式 从查找到知乎页面开始:https://www.zhihu.com/question/27982282 到mnist example页面:http://caffe.berkeleyvis ...

  10. Linux上jdk安装及环境变量设置

    1.jdk下载和安装 (1)http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html下载需 ...