http://poj.org/problem?id=2151 (题目链接)

题意

  T支队伍,一共M道题,第i支队伍解出第j道题的概率为p[i][j]。问每支队伍至少解出1道题并且解题最多的的队伍至少解出N道题的概率。

Solution

  我终于明白了,这种题目,永远也不要想着去搞清楚样例是怎么算出来的,只要列出你认为正确的dp方程就行了。。

  于是这道题,令${f_{i,j,k}}$表示第i个队伍,前j道题,解出k道的概率。转移很显然:

$${f_{i,j,k}=f_{i,j-1,k-1}*p_{i,j}+f_{i,j-1,k}*(1-p_{i,j})}$$

  再令${s_{i,j}}$表示第i个队伍解出的题目数小于等于j道的概率,那么很显然:

$${s_{i,j}=s_{i,j-1}+f_{i,m,j}}$$

  于是每个队伍解出的题目数再范围${1,M}$的概率p1(也就是至少解出一道题):

$${p1=\prod_{i=1}^{t}(1-s_{i,0})}$$

  每个队伍解出的题目数在范围${1,N-1}$的概率p2(每个队伍都至少解出一道题,但没有一支队伍解题数大于等于N):

$${p2=\prod_{i=1}^{t}(s_{i,N-1}-s_{i,0})}$$

  那么最后的答案:p1-p2

代码

// poj2151
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define inf 1<<30
#define eps 1e-8
#define Pi acos(-1.0)
#define free(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
using namespace std; const int maxt=1010,maxm=40;
double f[maxt][maxm][maxm],s[maxt][maxm],p[maxt][maxm];
int n,m,t; int main() {
while (scanf("%d%d%d",&m,&t,&n)!=EOF && m && t && n) {
memset(f,0,sizeof(f));
for (int i=1;i<=t;i++)
for (int j=1;j<=m;j++) scanf("%lf",&p[i][j]);
for (int i=1;i<=t;i++) {
f[i][0][0]=1;
for (int j=1;j<=m;j++)
for (int k=0;k<=j;k++) {
f[i][j][k]=f[i][j-1][k]*(1-p[i][j]);
if (k) f[i][j][k]+=f[i][j-1][k-1]*p[i][j];
}
s[i][0]=f[i][m][0];
for (int j=1;j<=m;j++) s[i][j]=s[i][j-1]+f[i][m][j];
}
double p1=1,p2=1;
for (int i=1;i<=t;i++) p1*=1-s[i][0],p2*=(s[i][n-1]-s[i][0]);
printf("%.3lf\n",p1-p2);
}
return 0;
}

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

  1. 【POJ2151】Check the difficulty of problems

    题意 某场比赛有M道问题,T支队伍,和数字N给出每支队伍解决每道问题的概率. 问这场比赛满足下面两个条件的概率 1.每支队伍至少做出一道题 2.冠军队至少做出N道题. 分析 条件2是不是可以转化为 至 ...

  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. PHP数组的基础知识

  2. 重新诠释的OSGi规范

    上周五部门开会讨论新一代产品(基于.net Winform)的设计规范,从设计规范慢慢讨论到体系结构等架构存在的问题,诸如菜单.工具条.状态条.界面布局等不能实现配置化和自动化,子系统之间拥有强依赖, ...

  3. ArcGIS Engine开发之地图基本操作(3)

    地图数据的加载 一.加载Shapefile数据 Shapefile文件是目前主流的一种空间数据的文件存储方式,也是不同GIS软件进行数据格式转换常用的中间格式.加载Shapefile数据的方式有两种: ...

  4. Event Handler

    在Event Handler中,有一种特殊的Event Handler,称之为Synchronizer或者Denormalizer,其作用就是为了同步“Query Database”.Query Da ...

  5. ASP.NET MVC 5 01 - ASP.NET概述

    本篇目录: ASP.NET 概述 .NET Framework 与 ASP.NET ASP.NET MVC简介 ASP.NET的特色和优势 典型案例 ▁▃▅ ASP.NET概述 ▅▃▁ 目前开发B/S ...

  6. 在Ubuntu X64上编译Hadoop

    在之前的文章中介绍了如何直接在Ubuntu中安装Hadoop.但是对于64位的Ubuntu来说,官方给出的Hadoop包是32位的,运行时会得到警告: WARN util.NativeCodeLoad ...

  7. zabbix 中监控windows 的typepref中的值

    监控项:typepref -qx在zabbix中实现: 1.测试zabbix-get 获取数据: /usr/local/zabbix/bin/zabbix_get -s 192.168.1.3 -p1 ...

  8. Linux下的TeXlive 2015 中文问题

    Update: 今日突然发现,我的xeLaTeX编译生成的pdf中文字在TeXMaker内置viewer.evince下查看均无法显示中文,中文字显示为空白,英语正常:但FireFox.Chrome浏 ...

  9. webgl 循环传参画10个点

    function main(){ var canvas = document.getElementById("webgl"); var gl = getWebGLContext(c ...

  10. Subsets II

    Given a collection of integers that might contain duplicates, nums, return all possible subsets. Not ...