Collecting Bugs(POJ 2096)
| Time Limit: 10000MS | Memory Limit: 64000K | |
| Total Submissions: 3064 | Accepted: 1505 | |
| Case Time Limit: 2000MS | Special Judge |
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
Source
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
#define ll long long
#define _cle(m, a) memset(m, a, sizeof(m))
#define repu(i, a, b) for(int i = a; i < b; i++)
#define MAXN 1005 double d[MAXN][MAXN];
int main()
{
int n, s;
while(~scanf("%d%d", &n, &s))
{
_cle(d, );
for(int i = n; i >= ; i--)
for(int j = s; j >= ; j--) {
if(i == n && j == s) ;
else {
d[i][j] = ((d[i + ][j + ] + 1.0) * (double)((n - i) * (s - j))
+ (d[i + ][j] + 1.0) * (double)((n - i) * (j))
+ (d[i][j + ] + 1.0) * (double)((i) * (s - j))
+ i * j) / (double)(n * s - i * j);
}
}
printf("%.4lf\n", d[][]);
}
return ;
}
Collecting Bugs(POJ 2096)的更多相关文章
- poj2096 Collecting Bugs(概率dp)
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 1792 Accepted: 832 C ...
- 【POJ】2096 Collecting Bugs(数学期望)
题目 传送门:QWQ 分析 数学期望 用$ dp[i][j] $表示发现了在$ j $个子系统里面发现了$ i $个bug到$ s $个子系统里面发现了$ n $个bug需要的期望天数. $ dp[0 ...
- POJ - 2096 Collecting Bugs(概率dp)
https://vjudge.net/problem/POJ-2096 题意 一个软件有s个子系统,会产生n种bug.某人一天发现一个bug,这个bug属于某种bug,发生在某个子系统中.求找到所有的 ...
- poj 2096 Collecting Bugs(期望 dp 概率 推导 分类讨论)
Description Ivan is fond of collecting. Unlike other people who collect post stamps, coins or other ...
- [Poj2096]Collecting Bugs(入门期望dp)
Collecting Bugs Time Limit: 10000MS Memory Limit: 64000K Total Submissions: 6237 Accepted: 3065 ...
- 01背包问题:Charm Bracelet (POJ 3624)(外加一个常数的优化)
Charm Bracelet POJ 3624 就是一道典型的01背包问题: #include<iostream> #include<stdio.h> #include& ...
- Scout YYF I(POJ 3744)
Scout YYF I Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5565 Accepted: 1553 Descr ...
- 广大暑假训练1(poj 2488) A Knight's Journey 解题报告
题目链接:http://vjudge.net/contest/view.action?cid=51369#problem/A (A - Children of the Candy Corn) ht ...
- Games:取石子游戏(POJ 1067)
取石子游戏 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 37662 Accepted: 12594 Descripti ...
随机推荐
- 浏览器被hao.360.cn劫持怎么办
特么的现在互联网太没节操了,一大早发现我的浏览器被hao.360.cn劫持了,弄了好久都没弄好,后来一想可能是因为qvod的原因,这可是哥当年看片的神器啊…… 废话不说: 1,进入:C:\Progra ...
- [SAP ABAP开发技术总结]物料、生产、采购、销售长文本
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- linux配置IP地址
1. ifconfig命令临时配置IP地址 ifconfig命令:查看与配置网络状态命令 如: ifconfig eht0 192.168.0.200 netmask 255.255.255.0 # ...
- bzoj 1202: [HNOI2005]狡猾的商人 并查集好题
1202: [HNOI2005]狡猾的商人 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2946 Solved: 1384[Submit][Sta ...
- SQLserver批量删除空表
今天需要清理一个很大的数据库,里面表有一堆,而且有很多是空表.想着把数据库弄小点,于是想到一次性删掉所有空表. 废话不多说,上代码. 首先,查处所有的空表. select distinct a.nam ...
- apiCloud结合layer实现动态数据弹出层
css /** 我的二维码 begin **/ .aui-list .wechat-media { width: 3rem; } .wechat-middle { padding: 1.3em 3.2 ...
- wireshark使用教程
Wireshark: https://www.wireshark.org/ 安装: apt-get install wireshark 教程: http://blog.csdn.net/leichel ...
- 转:内存区划分、内存分配、常量存储区、堆、栈、自由存储区、全局区[C++][内存管理][转载]
内存区划分.内存分配.常量存储区.堆.栈.自由存储区.全局区[C++][内存管理][转载] 一. 在c中分为这几个存储区1.栈 - 由编译器自动分配释放2.堆 - 一般由程序员分配释放,若程序员不释放 ...
- Mybatis调用Mysql存储过程
在我的后台系统中,今天需要使用到存储过程.存储过程还真没写过,今天就写了个存储过程.使用在后台中. 其实这个接口功能 是涉及几张表的修改,删除,新增的.就写个一个存储过程. 存储过程: ), ),) ...
- Hbase之更新单条数据
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; impo ...