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 ...
随机推荐
- Java编译环境的搭建(eclipse)
每用一种语言开发,要搭建其编译和开发环境,我们废话不说,立刻来看看Java开发环境的搭建. 1.安装JDK和JRE Windows环境下: a.去Oracle官网下载对应版本的JDK安装包,http: ...
- [C和指针]第一部分
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- XML约束——DTD约束
参考: 方立勋老师的讲课视频. 什么是XML约束 •在XML技术里,可以编写一个文档来约束一个XML文档的书写规范,这称之为XML约束. 为什么需要XML约束 常用的约束技术 •XML DTD • ...
- js一些问题总结
1.undefined与null与NAN的区别 undefined表示未申明,null表示申明了没定义为空值,NAN表示不是数据类型.
- poj3347Kadj Squares
链接 这题其实与几何没太大关系,还不错的题目. 参考吴永辉的算法设计书. 用lefi.rigi分别表示正方形在x轴上的投影. 为了避免用小数,把边长都扩大sqrt(2)倍,这样lef1 = 0,rig ...
- (三)NAND flash和NOR flash的区别详解
我们使用的智能手机除了有一个可用的空间(如苹果8G.16G等),还有一个RAM容量,很多人都不是很清楚,为什么需要二个这样的芯片做存储呢,这就是我们下面要讲到的.这二种存储设备我们都统称为“FLASH ...
- 下载安装APK
protected void downloadApk() { //apk下载链接地址,放置apk的所在路径 //1,判断sd卡是否可用,是否挂在上 if(Environment.getExternal ...
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
Android 高手进阶(21) 版权声明:本文为博主原创文章,未经博主允许不得转载. 转载请注明出处:http://blog.csdn.net/xiaanming/article/detail ...
- java中的堆内存和栈内存
Java把内存分成两种: 一种叫做栈内存 一种叫做堆内存 栈内存 : 在函数中定义的一些基本类型的变量和对象的引用变量都是在函数的栈内存中分配.当在一段代码块中定义一个变量时,java就在栈中为这个变 ...
- mysql 批处理文件--- 创建 用户 以及 导入数据
在window下,通过批处理文件(.bat),进行开启MYSQL服务,导入数据文件(.sql) 1)新建一个txt文件,写入以下内容 rem 启动mysql56服务 mysql56是我的mysql服 ...