POJ2151Check the difficulty of problems
题意 : 举办一次比赛不容易,为了不让题目太难,举办方往往希望能够讲出的题目满足两点,1是所有的队伍都至少能够解出一个题目,2是冠军队至少能解出确定数量的题目,最后让你求的是每个队伍至少解出一道题并且冠军队伍解出N道题的概率.
思路 : 我觉得吧,搞ACM不容易,唉,概率这玩意儿,一不小心漏掉一个就完啦。。。。首先呢,概率得好好求,其次呢DP得会一些。。。。
这个题的思路我觉得小优姐的CSDN已经说得很详细了http://blog.csdn.net/lyy289065406/article/details/6648579
样例解释 : 2 2 2
0.9 0.9
1 0.9
第一行M,T,N代表着M道题,T个队伍,希望冠军队做出N道题。接下来是T行M列,表示(i,j)点表示队伍 i 做对 j题的概率是多少。
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std ;
const int maxn = ;
const int maxm = ;
double f[maxm][maxn];
double dp[maxm][maxn][maxn];
int main()
{
int M,T,N ;//题目数,队伍数,冠军队做出题目数
while(~scanf("%d %d %d",&M,&T,&N))
{
if(M == &&N == && T == )
break ;
memset(dp,,sizeof(dp));
for(int i = ; i <= T ; i++)
{
for(int j = ; j <= M ; j++)
scanf("%lf",&f[i][j]);
}
for(int i = ; i <= T ; i++)
{
dp[i][][] = 1.0 ;
for(int j = ; j <= M ; j++)
{
dp[i][j][] = dp[i][j-][]*(-f[i][j]);
for(int k = ; k <= j ; k++)
{
dp[i][j][k] = dp[i][j-][k-]*f[i][j]+dp[i][j-][k]*(-f[i][j]);
}
}
}
double p1 = 1.0 ;
for(int i = ; i <= T ; i++)
p1 *= ( - dp[i][M][]) ;
double p2 = 1.0 ;
for(int i = ; i <= T ; i++)
{
double sum = ;
for(int j = ; j < N ; j++)
sum += dp[i][M][j];
p2 *= sum ;
}
printf("%.3f\n",p1-p2); }
return ;
}
POJ2151Check the difficulty of problems的更多相关文章
- POJ2151-Check the difficulty of problems(概率DP)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4512 ...
- poj2151--Check the difficulty of problems(概率dp第四弹,复杂的计算)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5009 ...
- POJ2151-Check the difficulty of problems
题目链接:点击打开链接 Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submiss ...
- POJ2151Check the difficulty of problems 概率DP
概率DP,还是有点恶心的哈,这道题目真是绕,问你T个队伍.m个题目.每一个队伍做出哪道题的概率都给了.冠军队伍至少也解除n道题目,全部队伍都要出题,问你概率为多少? 一開始感觉是个二维的,然后推啊推啊 ...
- POJ 2151 Check the difficulty of problems
以前做过的题目了....补集+DP Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K ...
- Check the difficulty of problems
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5830 Acc ...
- Check the difficulty of problems(POJ 2151)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5457 ...
- POJ 2151 Check the difficulty of problems (动态规划-可能DP)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4522 ...
- POJ 2151 Check the difficulty of problems 概率dp+01背包
题目链接: http://poj.org/problem?id=2151 Check the difficulty of problems Time Limit: 2000MSMemory Limit ...
随机推荐
- 解决Eclipse中Java工程间循环引用而报错的问题
如果myeclipse 报如下错误 A cycle was detected in the build path of project 如果我们的项目包含多个工程(project),而它们之间又是循 ...
- html关于强制显示 隐藏浏览器的滚动条
浏览器的滚动条在一些特殊的展示中,是不需要的,所以必须把它隐藏掉,文章主要介绍一些隐藏或者显示IE的水平或者垂直滚动条的实现代码,需要了解的朋友可以参考下: 相关css代码如下: //强制显示滚动条: ...
- phpcms v9 源码解析(3)pc_base::creat_app()
69 return self::load_sys_classs('application'); 在前面我们已经知道了,这个load_sys_classs 静态方法,它加载了P ...
- Ztack学习笔记(1)-初识Ztack
一.Zigbee协议 Zigbee是IEEE 802.15.4协议的代名词,是一种短距离.低功耗的无线通信技术.这一名称来源于蜜蜂的八字舞,因为蜜蜂(bee)是靠飞翔和“嗡嗡”(zig)地抖动翅膀的“ ...
- 基于WCF的API实现
本文程序基于VS2013.EF6.1.WCF WCF有2种方式,一是SOAP,一种是Restful 由于程序是基于PCL(可移植类库)的,所以不能用直接引入WCF服务的方式 网上的Restful方式的 ...
- Microsoft server software support for Microsoft Azure virtual machines
http://support.microsoft.com/kb/2721672/en-us Article ID: 2721672 - Last Review: November 22, 2014 ...
- SQLdiag Utility
使用SQLdiag 会进行信息搜集类型 Windows 系统性能日志 Windows 系统日志 SQL Server 性能信息 SQL Server 阻塞信息 SQL Server 配置信息 如何使用 ...
- [转] 浅谈Microsoft MVP
微软MVP,这个自1993 年开始在社群上出现的计划(MVP Award Program),目前在全球已经累积超过5,000 人,其中在台湾已经有一百多人了,包括我在内,这个计画现在已经成为以微软技术 ...
- MySQL主从修复
MySQL主从故障修复 测试库:192.168.1.2 主192.168.1.3 从 192.168.1.4 主 4又是2的从库192.168.1.5 从 有人修改了192.168.1.2和192.1 ...
- python之super()函数
python之super()函数 python的构造器奇特, 使用魔方. 构造器内对基类对象的初始化同样也很奇特, 奇特到没有半点优雅! 在构造器中使用super(class, instance)返回 ...