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 ...
随机推荐
- 引入OO开发报表后的感想
很早就想尝试着在常规的报表开发中 引入OO了 趁着程序略复杂 时间略充裕 终于尝试了一把-咩哈哈~~ 以下来自我的evernote笔记 有点语无伦次-忍忍~~ -------------------- ...
- App性能提升方法
总体思路:精简请求数 1.css sprit 图像拼合,将所有可拼接的所有图像拼接为一整张图像,然后再利用css中的position定位来处理,降低图片的请求数 2.懒加载:只渲染客户端用户可见区域[ ...
- linux terminal 日常shell
1 ubuntu中如何将终端添加到右键 /home/cui/.local/share/nautilus/scripts #!/bin/bash #cd $NAUTILUS_SCRIPT_CURRENT ...
- 而在Jquery中则使用$.map()、$.each()来操作数组
首先是普通的数组(索引为整数的数组): //$.map(arr,fn); //对数组中的每个元素调用fn函数逐个进行处理,fn函数将处理返回最后得到的一个新的数组 var arr = [9, 8, 7 ...
- 查询sql语句所花时间
--1:下面这种是SQL Server中比较简单的查询SQL语句执行时间方法,通过查询前的时间和查询后的时间差来计算的: declare @begin_date datetime declare @e ...
- 集成环境wamp环境下 memcached的安装
早就听说过memcached,但是一直没实践过.所有今天有时间就搞了一下,哎废了我一上午才搞定!一上午啊,好丢人.特写记录一下 先说一下我遇到的问题:按照别人教程(还有好多)说的,安装后没有任何的错误 ...
- jdbc连接数据库使用sid和service_name的区别
问题描述: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor The Connect ...
- Java eclipse export jar包 包括第三方引入的jar
1.安装fatjar插件 2.export jar 说明:安装后,操作说明以官网为准,不同的版本会有不同的右键菜单,我的版本(Eclipse Java EE IDE for Web Developer ...
- ApacheBench 使用教程
ab压力测试 ab是Apache超文本传输协议(HTTP)的性能测试工具.其设计意图是描绘当前所安装的Apache的执行性能. 主要是显示你安装的Apache每秒可以处理多少个请求. 格式: ./ab ...
- Oracle收缩表空间
可以使用 alter database datafile 'file path...' resize xM 的命令来缩小数据文件. SELECT 'alter database datafile '' ...