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 ...
随机推荐
- UIView背景渐变三种方法
//此作品非原创 #import "ACViewController.h" @interface ACViewController () @end @implementation ...
- 8.samba server与client配置
server端 1.安装samba:yum install -y samba\* 增加samba用户: useradd smb用户名 smbpasswd -a smb用户名 ...
- 问题:LVM lvextend增加空间后,df查看还是原来空间
1.LVM的调整空间大小: #lvextend -L +1300M /dev/mapper/ycgsstore_sdb-wmy #lvdisplay wmy ycgsstore_sdb -wi-ao- ...
- linux系统版本查看命令
发布:theboy 来源:net [大 中 小] 查看linux系统版本的命令 有如下命令可供参考: # lsb_release -a LSB Version: :core-3.1-ia ...
- js阻止冒泡事件及默认操作
1. 事件目标 现在,事件处理程序中的变量event保存着事件对象.而event.target属性保存着发生事件的目标元素.这个属性是DOM API中规定的,但是没有被所有浏览器实现 .jQuery对 ...
- 《零成本实现Web自动化测试--基于Selenium》第一章 自动化测试基础
第一篇 Selenium 和WebDriver工具篇 第一章 自动化测试基础 1.1 初识自动化测试 自动化测试有两种常见方式 1.1.1 代码驱动测试,又叫测试驱动开发(TDD) 1.1.2 ...
- Log.i()的用法
2011-04-16 09:44 17486人阅读 评论(4) 收藏 举报 androidlayoutbuttonstringencodingeclipse 在调试代码的时候我们需要查看调试信息,那我 ...
- 幻灯slider
<style> .focusBox { position: relative; width: 340px; height: 240px; overflow: hidden; font: 1 ...
- 自定义控件(模仿微信ToggleButton控件)
弄过android开发的都知道,系统有一个默认的ToggleButton,但很多人都觉得他很难看,当然也包括我.如果你感觉他不难看,那你就继续使用系统的吧,这篇文章对你来说是多余的了. 今天来写一个模 ...
- iOS开发网络篇—大文件的多线程断点下载(转)
http://www.cnblogs.com/wendingding/p/3947550.html iOS开发网络篇—多线程断点下载 说明:本文介绍多线程断点下载.项目中使用了苹果自带的类,实现了 ...