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

 
题意 :t个队伍m道题,i队写对j题的概率为pij。冠军是解题数超过n的解题数最多的队伍之一,求满足有冠军且其他队伍解题数都大于等于1的概率。
 
f[i][j][w]表示i队到第j题总共解出w道题的概率.
为了避免重复计数;
pa=所有队伍到最后一道题时的解题数都大于1的概率;
pb=所有队伍到最后一道题时解题数都小于n的概率;
答案为pa-pb.
 
代码如下
 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;
const int maxn=;
const double eps=1e-;
const int modn=;
int m,n,t;
double f[maxn][][]={};
double f1[maxn][]={};
double a[maxn][];
int main(){
while(~scanf("%d%d%d",&m,&t,&n)){
memset(f,,sizeof(f));
if(m==&&n==&&t==)break;
for(int i=;i<=t;i++){
for(int j=;j<=m;j++){
scanf("%lf",&a[i][j]);
}
}
double t1=,t2=,t3,t4;
for(int i=;i<=t;i++){
f[i][][]=;
for(int j=;j<=m;j++){
for(int w=;w<=j;w++){
if(j->=w)f[i][j][w]+=f[i][j-][w]*(1.0-a[i][j]);
f[i][j][w]+=f[i][j-][w-]*a[i][j];
}
}
t3=,t4=;
for(int j=;j<=m;j++){
t3+=f[i][m][j];
if(j<n){
t4+=f[i][m][j];
}
}
t1*=t3;t2*=t4;
}
printf("%.3f\n",t1-t2);
}
return ;
}

POJ2157 Check the difficulty of problems 概率DP的更多相关文章

  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. [ACM] POJ 2151 Check the difficulty of problems (概率+DP)

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

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

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

  4. [POJ2151]Check the difficulty of problems (概率dp)

    题目链接:http://poj.org/problem?id=2151 题目大意:有M个题目,T支队伍,第i个队伍做出第j个题目的概率为Pij,问每个队伍都至少做出1个题并且至少有一个队伍做出N题的概 ...

  5. [poj2151]Check the difficulty of problems概率dp

    解题关键:主要就是概率的推导以及至少的转化,至少的转化是需要有前提条件的. 转移方程:$dp[i][j][k] = dp[i][j - 1][k - 1]*p + dp[i][j - 1][k]*(1 ...

  6. POJ2151Check the difficulty of problems 概率DP

    概率DP,还是有点恶心的哈,这道题目真是绕,问你T个队伍.m个题目.每一个队伍做出哪道题的概率都给了.冠军队伍至少也解除n道题目,全部队伍都要出题,问你概率为多少? 一開始感觉是个二维的,然后推啊推啊 ...

  7. poj 2151Check the difficulty of problems<概率DP>

    链接:http://poj.org/problem?id=2151 题意:一场比赛有 T 支队伍,共 M 道题, 给出每支队伍能解出各题的概率~  求 :冠军至少做出 N 题且每队至少做出一题的概率~ ...

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

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

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

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

随机推荐

  1. PHP数据库类

    简单封装PHP操作MySQL的类 <?php /* 类的名称:Model 类的作用:连接数据库执行sql语句 作 者:lim 更新时间:20170812 */ class Model{ //存放 ...

  2. java中的matches -> 完全匹配

    matches是完全匹配.跟matcher不一样, matcher像perl正则, 能匹配到符合的都会返回true, 而这个matches要完全一模一样才行. import java.util.reg ...

  3. sniffer简单使用

    跟wireshark类似. 只是说显示的容易忘记所以丢张图记录一下. 该工具还是很坑爹的,不是比赛要用到所以都不是很想弄.一般机器运行不起来.不是蓝屏就是装了运行不了各种闪退,找了学校一台内网服务器才 ...

  4. 38 - 网络编程-socketserver

    目录 1 socket编程弊端 2 SocketServer模块 2.1 服务器类 2.2 Mixin类 2.3 RequestHandlerClass是啥 2.4 编程接口 3 实现EchoServ ...

  5. C语言回调函数总结

    /* Main program ---calls--> Library function ---calls--> Callback funtion */ #include <stdi ...

  6. javascript 之数据类型--01

    写在前面 国庆整理资料时,发现刚开始入门前端时学习JS 的资料,打算以一个基础入门博客记录下来,有不写不对的多多指教: 先推荐些书籍给需要的童鞋 <JavaScript 高级程序设计.pdf&g ...

  7. leetcode 之Permutation(七)

    首先是next permutation的算法的描述和分析如下: 这题一是要知道思路,编程中注意STL的用法 void nextPermutaion(vector<int> &num ...

  8. 当想把html element里面的text提取出来可以试着用正则

    var a='123<span>456</span><span class="active">789</span>'; a.repl ...

  9. WordPress 用户管理插件 WP User Manager

    WP User Manager 是一个较新的用户管理插件,可以在前端实现 用户注册.登录.找回密码.修改个人资料.修改密码等功能,如果你在找这方面的插件,WP User Manager 应该是一个不错 ...

  10. Cookie机制和Session机制

    1. cookie 1. Cookie 是在HTTP协议下,服务器或脚本可以维护客户工作站上信息的一种方式.Cookie 是由 Web服务器保存在用户浏览器(客户端)上的小文本文件(内容通常经过加密) ...