题意

某场比赛有M道问题,T支队伍,和数字N给出每支队伍解决每道问题的概率。 问这场比赛满足下面两个条件的概率

1.每支队伍至少做出一道题

2.冠军队至少做出N道题。

分析

条件2是不是可以转化为 至少有一支队做出N道及以上道题。

这个题主要是概率,其次才是dp,而且好像不算概率DP。

我们来倒推一下。

设p2为每支队伍做出来的题数都在(1-N-1)的概率。p1为每只队伍至少做出来一道题的概率。那么答案就是p1-p2。

然后我们再来想怎么求p1和p2。设s[i][j]为第i支队伍做出来题数小于等于j的概率。那么

p1=(1-s[1][0])*(1-s[2][0])*...*(1-s[T][0]).

p2=(s[1][N-1]-s[1][0])*(s[2][N-1]-s[2][0])*...*(s[T][N-1]-s[T][0])。

然后再往前推。s[i][j]该怎么求?

我们发现队伍与队伍之间没有关系,于是我们可以每支队伍都通过dp求解。对于每支队伍k

我们令f[i][j]为前i个问题中做出来j个题的概率 f[i][j]=f[i-1][j]*(1-P[k][j])+f[i-1][j-1]*P[k][j];

然后 s[k][j]=sum(f[M][l])(0<=l<=j)

就是这个样子。

这个题的DP是最基础的,但是概率那里我觉得不是特别好想。。(可能因为我菜吧···)

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std;
const int maxn=+;
const int maxm=;
int M,T,N;
double P[maxn][maxm];
double f[maxm][maxm],s[maxn][maxm];
int main(){
while(scanf("%d%d%d",&M,&T,&N)!=EOF&&(M||T||N)){
memset(P,,sizeof(P));
for(int i=;i<=T;i++){
for(int j=;j<=M;j++){
scanf("%lf",&P[i][j]);
}
memset(f,,sizeof(f));
f[][]=1.0;
for(int j=;j<=M;j++){
for(int k=;k<=j;k++){
if(k==)
f[j][k]=f[j-][k]*(-P[i][j]);
else
f[j][k]=f[j-][k-]*P[i][j]+f[j-][k]*(-P[i][j]);
}
}
double sum=;
for(int j=;j<=M;j++){
sum+=f[M][j];
s[i][j]=sum;
}
}
double p1,p2;
p1=p2=1.0;
for(int i=;i<=T;i++){
p1*=(-s[i][]);
}
for(int i=;i<=T;i++){
p2*=(s[i][N-]-s[i][]);
}
double ans=p1-p2;
printf("%.3f\n",ans);
}
return ;
}

【POJ2151】Check the difficulty of problems的更多相关文章

  1. 【poj2151】 Check the difficulty of problems

    http://poj.org/problem?id=2151 (题目链接) 题意 T支队伍,一共M道题,第i支队伍解出第j道题的概率为p[i][j].问每支队伍至少解出1道题并且解题最多的的队伍至少解 ...

  2. 【POJ】【2151】Check the difficulty of problems

    概率DP kuangbin总结中的第8题 一开始题目看错导致想转移方程想错了……想成f[i][j]表示前 i 个队伍中最多的做出来 j 道题的概率……sigh 看了下题解……其实是对于每个队伍 i 单 ...

  3. 【POJ】2151:Check the difficulty of problems【概率DP】

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8903   ...

  4. POJ 2151 Check the difficulty of problems

    以前做过的题目了....补集+DP        Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K ...

  5. Check the difficulty of problems

    Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5830 Acc ...

  6. Check the difficulty of problems(POJ 2151)

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5457   ...

  7. POJ 2151 Check the difficulty of problems (动态规划-可能DP)

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4522   ...

  8. POJ 2151 Check the difficulty of problems 概率dp+01背包

    题目链接: http://poj.org/problem?id=2151 Check the difficulty of problems Time Limit: 2000MSMemory Limit ...

  9. [ACM] POJ 2151 Check the difficulty of problems (概率+DP)

    Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4748   ...

随机推荐

  1. html页面设置一个跟随鼠标移动的DIV(jQuery实现)

    说明业务:鼠标放到某个标签上,显示一个div,并跟随鼠标移动 html页面(直接放body里面): <a href="#" id="'+data[i].refund ...

  2. parceljs 基本使用———又一个前端构建工具

    备注:      又一个新的前端构建工具 1. 安装 yarn global add parcel-bundler 2. 初始化项目 yarn init -y 3. 基本代码 a. 创建 index. ...

  3. table样式的下拉框(angularjs)

    前言 虽然使用的技术比较老了,但是思想却还是适用于现在的vue等框架. 一:实现的样式 二:实现包括的功能点 1:下拉框内容是表格,类似于一个弹窗 表格内容最多六行,超出的显示滚动条,表头固定,可滚动 ...

  4. RK3288 修改浏览器默认主页和书签

    path:packages/apps/Browser/res/values/strings.xml 修改浏览器默认主页: <!-- The default homepage. --> &l ...

  5. codechef January Challenge 2017 简要题解

    https://www.codechef.com/JAN17 Cats and Dogs 签到题 #include<cstdio> int min(int a,int b){return ...

  6. com.mysql.jdbc.PacketTooBigException: Packet for query is too large (4593 > 1024)

    修改 my.conf ,增加max_allowed_packet=8M window中, 进入mysql的 bin目录 执行  :修改 my.conf ,增加max_allowed_packet=8M

  7. 超详细的php用户注册页面填写信息完整实例(附源码)

    这篇文章主要介绍了一个超详细的php用户注册页面填写信息完整实例,内容包括邮箱自动匹配.密码强度验证以及防止表单重复等,小编特别喜欢这篇文章,推荐给大家. 注册页面是大多数网站必备的页面,所以很有必要 ...

  8. questions information

    1. 面向对象 类(Class): 用来描述具有相同的属性和方法的对象的集合.它定义了该集合中每个对象所共有的属性和方法.对象是类的实例. 三大特性: 封装: -- 将内容封装到对象中 -- 将方法疯 ...

  9. 通过TortoiseGit来使用Github或Visual Studio Online版本控制管理

    一.前言 关于Git源码不再多阐述,它就是一款开源分布式版本控制工具,它在源码管理领土上目前为止,使用者比例很大,越来越多的人使用该工具来管理项目源码,且相当多的开源的项目都移步到Github中,如: ...

  10. 类名+函数名(参数1,参数2.....){.......return this;}

    下述的函数是这样定义的: 类名+函数名(参数1,参数2.....){.......return this;} int +函数名(参数1,参数2.....){.......return int;} sh ...