http://poj.org/problem?id=2151

题意:T个队伍M条题目,给出每个队伍i的每题能ac的概率p[i][j],求所有队伍至少A掉1题且冠军至少A掉N题的概率(T<=1000, M<=30)

#include <cstdio>
#include <cstring>
using namespace std;
const int T=1005, M=35;
double d[T][M], p[T][M];
int n, m, N;
void clr() {
for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) d[i][j]=0;
}
int main() {
while(scanf("%d%d%d", &m, &n, &N), !(m==0&&n==0&&N==0)) {
for(int i=1; i<=n; ++i) for(int j=1; j<=m; ++j) scanf("%lf", &p[i][j]);
for(int i=1; i<=n; ++i) d[i][0]=1;
for(int i=1; i<=n; ++i)
for(int k=1; k<=m; d[i][0]*=1-p[i][k], ++k)
for(int j=m; j; --j) d[i][j]=d[i][j]*(1-p[i][k])+d[i][j-1]*p[i][k];
//for(int i=1; i<=n; ++i) { for(int j=0; j<=m; ++j) printf("%.2f ", d[i][j]); puts(""); }
for(int i=1; i<=n; ++i) for(int j=m; j; --j) d[i][j]+=d[i][j+1];
double ans=0, sum;
for(int i=1; i<=n; ++i) {
sum=d[i][N];
for(int j=1; j<i; ++j) sum*=(d[j][1]-d[j][N]);
for(int j=i+1; j<=n; ++j) sum*=d[j][1];
ans+=sum;
}
printf("%.3f\n", ans);
clr();
}
return 0;
}

  

我们只需要设状态就行了= =随便搞...

设f[i][j][k]表示第i队解决j~k个问题的概率

$$ans=\sum_{i} \left( f[i][N][M] * \prod_{j<i} f[j][1][N-1] * \prod_{j>i} f[j][1][M] \right) $$

这样就能不重不漏....(不难理解,我觉得这个很简单的吧= =

然后我们来一发前缀和,d[i][j]表示第i队解决至少j个问题的概率

$$ans=\sum_{i} \left( d[i][N] * \prod_{j<i} ( d[j][1]-d[j][N] ) * \prod_{j>i} d[j][1] \right) $$

问题转化为如何求d[i][j]...

设d'[i][j]表示第i队解决j个问题的概率

我们类似背包依次加入每个问题,有

d[i][j]=d[i][j]*(1-p[i][k])+d[i][j-1]*p[i][k](自己好好思考= =,我拐了好多个弯才想出来QAQ

于是就ok了。。。

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

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

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

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

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

  3. POJ 2151 Check the difficulty of problems

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

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

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

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

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

  6. POJ 2151 Check the difficulty of problems:概率dp【至少】

    题目链接:http://poj.org/problem?id=2151 题意: 一次ACM比赛,有t支队伍,比赛共m道题. 第i支队伍做出第j道题的概率为p[i][j]. 问你所有队伍都至少做出一道, ...

  7. poj 2151 Check the difficulty of problems(概率dp)

    poj double 就得交c++,我交G++错了一次 题目:http://poj.org/problem?id=2151 题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 ...

  8. POJ 2151 Check the difficulty of problems (概率DP)

    题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 ,求每队至少解出一题且冠军队至少解出N道题的概率. 析:概率DP,dp[i][j][k] 表示第 i 个队伍,前 j 个题,解出 ...

  9. POJ 2151 Check the difficulty of problems (概率dp)

    题意:给出m.t.n,接着给出t行m列,表示第i个队伍解决第j题的概率. 现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少? 思路:求补集. 即所有队伍都解出题目的 ...

随机推荐

  1. Redis笔记(五)Redis的事务

    >>关系型数据库的事务 事务是应用程序中一系列严密的操作,所有操作必须成功完成,否则在每个操作中所作的所有更改都会被撤消. Atomic(原子性): 一个事务(transaction)中的 ...

  2. poj 3264:Balanced Lineup(线段树,经典题)

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 32820   Accepted: 15447 ...

  3. RMAN恢复目录

    是否使用RMAN恢复目录(Recovery Catalog 你可能从其他人或书上听过RMAN恢复目录(也有可能是其他名字,RMAN Recovery Catalog的翻译较多较杂,以下简称恢复目录), ...

  4. Intellij Idea 使用

    一.使用前需要修改的配置: 1.当类实现Serializable接口时,自动生成 serialVersionUID 1)Setting->Inspections->java->Ser ...

  5. 11g添加asm

    1.创建组 2.创建grid用户 3.用grid安装Gride Infrastructure软件 4.执行root.sh[root@ora11g softdb]# /u01/app/11.2.0/gr ...

  6. hdu 5306 优先队列

    用到优先队列 #include<iostream> #include<string> #include<algorithm> #include<cstdio& ...

  7. MySQL主主复制3

    一.创建并授权用户 在每一台(主)服务器上创建一个用户,并为之授权,使它们可以互相访问彼此的数据库 在Server-1上: 创建一个充许Server-2来访问的用户server2,密码为:server ...

  8. 理解是最好的记忆方法 之 CSS中a链接的④个伪类为何有顺序

    理解是最好的记忆方法 之 CSS中a链接的④个伪类为何有顺序 在CSS中,a标签有4种伪类,分别为: a:link, a:visited, a:hover, a:active 对其稍有了解的前端er都 ...

  9. constructor

    function Person(name){ this.name = name; } Person.prototype = { constructor : Person, sayName : func ...

  10. 2.使用Package Control组件安装

    安装Sublime Text 2插件的方法: 1.直接安装 安装Sublime text 2插件很方便,可以直接下载安装包解压缩到Packages目录(菜单->preferences->p ...