刷题总结——Collecting Bugs(poj2096)
题目:
Description
Two companies, Macrosoft and Microhard are in tight competition. Microhard wants to decrease sales of one Macrosoft program. They hire Ivan to prove that the program in question is disgusting. However, Ivan has a complicated problem. This new program has s subcomponents, and finding bugs of all types in each subcomponent would take too long before the target could be reached. So Ivan and Microhard agreed to use a simpler criteria --- Ivan should find at least one bug in each subsystem and at least one bug of each category.
Macrosoft knows about these plans and it wants to estimate the time that is required for Ivan to call its program disgusting. It's important because the company releases a new version soon, so it can correct its plans and release it quicker. Nobody would be interested in Ivan's opinion about the reliability of the obsolete version.
A bug found in the program can be of any category with equal probability. Similarly, the bug can be found in any given subsystem with equal probability. Any particular bug cannot belong to two different categories or happen simultaneously in two different subsystems. The number of bugs in the program is almost infinite, so the probability of finding a new bug of some category in some subsystem does not reduce after finding any number of bugs of that category in that subsystem.
Find an average time (in days of Ivan's work) required to name the program disgusting.
Input
Output
Sample Input
1 2
Sample Output
3.0000
题解:
期望dp入门题,详见http://blog.csdn.net/xingyeyongheng/article/details/25179481
主要是那个倒推的思想在期望dp中用得很多
代码:
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cctype>
#include<ctime>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=;
int n,s;
double f[N][N];
int main(){
//freopen("a.in","r",stdin);
while(scanf("%d%d",&n,&s)!=EOF){
memset(f,,sizeof(f));
for(int i=n;i>=;i--)
for(int j=s;j>=;j--){
if(i==n&&j==s) continue;
double p1=(n-i)*(s-j)*1.0/(n*s)*1.0;
double p2=i*(s-j)*1.0/(n*s)*1.0;
double p3=(n-i)*j*1.0/(n*s)*1.0;
double p4=i*j*1.0/(n*s)*1.0;
f[i][j]=(f[i+][j+]*p1+f[i][j+]*p2+f[i+][j]*p3+)/(-p4);
}
printf("%0.4f",f[][]);
}
return ;
}
刷题总结——Collecting Bugs(poj2096)的更多相关文章
- Collecting Bugs poj2096 概率DP
Collecting Bugs Time Limit: 10000MS Me ...
- 【POJ2096】Collecting Bugs 期望
[POJ2096]Collecting Bugs Description Ivan is fond of collecting. Unlike other people who collect pos ...
- poj2096 Collecting Bugs(概率dp)
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 1792 Accepted: 832 C ...
- [Poj2096]Collecting Bugs(入门期望dp)
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 6237 Accepted: 3065 ...
- poj2096 Collecting Bugs[期望dp]
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 5394 Accepted: 2670 ...
- POJ2096 Collecting Bugs(概率DP,求期望)
Collecting Bugs Ivan is fond of collecting. Unlike other people who collect post stamps, coins or ot ...
- 刷题记录:[SUCTF 2019]Pythonginx
目录 刷题记录:[SUCTF 2019]Pythonginx 一.涉及知识点 1. CVE-2019-9636:urlsplit不处理NFKC标准化 2.Nginx重要文件位置 二.解题方法 刷题记录 ...
- 刷题记录:[De1CTF 2019]SSRF Me
目录 刷题记录:[De1CTF 2019]SSRF Me 一.涉及知识点 1.MD5长度扩展攻击 2.Python 2.x - 2.7.16 urllib.fopen支持local_file导致LFI ...
- $2019$ 暑期刷题记录1:(算法竞赛DP练习)
$ 2019 $ 暑期刷题记录: $ POJ~1952~~BUY~LOW, BUY~LOWER: $ (复杂度优化) 题目大意:统计可重序列中最长上升子序列的方案数. 题目很直接的说明了所求为 $ L ...
随机推荐
- DongDong坐飞机
题目连接:https://ac.nowcoder.com/acm/contest/904/D 第一次研究了一下这种题型,还是比较好理解的,因为有半价次数的限制,所以要把每一中情况都写出来,dp[现在的 ...
- java打包打包
http://blog.sina.com.cn/s/blog_6b9dcc870101k8xq.html 上面说的最后一种方法,不太对. 下面这个可以 Try the fat-jar extensio ...
- Bootstrap 弹出框(Popover)插件
Bootstrap 弹出框(Popover)插件与Bootstrap 提示工具(Tooltip)插件类似,提供了一个扩展的视图,用户只需要把鼠标指针悬停到元素上面即可.弹出框的内容完全由Bootstr ...
- CSS清除浮动方法总结
什么是CSS清除浮动? 在非IE浏览器(如Firefox)下,当容器的高度为auto,且容器的内容中有浮动(float为left或right)的元素,在这种情况下,容器的高度不能自动伸长以适应内容的高 ...
- python 使用uuid 出现重复
同时保存入数据库时候 ,使用 uuid.uuid1() 后出现 重复的 id , 现在 修改为 (uuid.uuid5(uuid.NAMESPACE_DNS, str(uuid.uuid1()) ...
- Centos7之Nginx
1.安装 下载RPM: wget http://nginx.org/download/nginx-1.16.0.tar.gz 解压:tar -zxf nginx-1.16.0.tar.gz 安装: c ...
- k8s基于RBAC的访问控制(用户授权)
kubernetes的API Server常用的授权插件有: Node.ABAC.RBAC.Webhook我们重点说一下RBAC的访问控制逻辑RBAC(Role base access contr ...
- python网络-多任务实现之协程(27)
一.协程 协程,又称微线程,纤程.英文名Coroutine. 协程不是进程,也不是线程,它就是一个函数,一个特殊的函数——可以在某个地方挂起,并且可以重新在挂起处继续运行.所以说,协程与进程.线程相比 ...
- 动态规划:最长上升子序列之基础(经典算法 n^2)
解题心得: 1.注意动态转移方程式,d[j]+1>d[i]>?d[i]=d[j]+1:d[i] 2.动态规划的基本思想:将大的问题化为小的,再逐步扩大得到答案,但是小问题的基本性质要和大的 ...
- Network of Schools POJ - 1236 (强联通)
一些学校连接到了一个计算机网络.网络中的学校间有如下约定:每个学校维护一个列表,当该学校收到软件或信息后将会转发给列表中的所有学校(也就是接收方列表).需要注意的是如果B学校在A学校的接收方列表中,A ...