POJ 2151 Check the difficulty of problems
以前做过的题目了。。。。补集+DP
Time Limit: 2000MS | Memory Limit: 65536K | |
Total Submissions: 4091 | Accepted: 1811 |
Description
1. All of the teams solve at least one problem.
2. The champion (One of those teams that solve the most problems) solves at least a certain number of problems.
Now the organizer has studied out the contest problems, and through the result of preliminary contest, the organizer can estimate the probability that a certain team can successfully solve a certain problem.
Given the number of contest problems M, the number of teams T, and the number of problems N that the organizer expect the champion solve at least. We also assume that team i solves problem j with the probability Pij (1 <= i <= T, 1<= j <= M). Well, can you calculate the probability that all of the teams solve at least one problem, and at the same time the champion team solves at least N problems?
Input
Output
Sample Input
2 2 2
0.9 0.9
1 0.9
0 0 0
Sample Output
0.972
Source
POJ Monthly,鲁小石
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; int M,T,N;
double a[][][],s[][],p1,pn,solve[][]; int main()
{
while(~scanf("%d%d%d",&M,&T,&N))
{
if((M||T||N)==) break;
for(int i=;i<=T;i++) for(int j=;j<=M;j++) scanf("%lf",&solve[i][j]);
memset(a,,sizeof(a)); memset(s,,sizeof(s));
for(int i=;i<=T;i++)
{
a[i][][]=;
for(int j=;j<=M;j++)
{
a[i][j][]=a[i][j-][]*(-solve[i][j]);
}
}
for(int i=;i<=T;i++)
{
for(int j=;j<=M;j++)
{
for(int k=;k<=j;k++)
{
a[i][j][k]=a[i][j-][k-]*solve[i][j]+a[i][j-][k]*(-solve[i][j]);
}
}
}
for(int i=;i<=T;i++)
{
s[i][]=a[i][M][];
for(int j=;j<=M;j++)
{
s[i][j]=s[i][j-]+a[i][M][j];
}
}
p1=pn=.;
for(int i=;i<=T;i++)
{
p1*=s[i][M]-s[i][];
pn*=s[i][N-]-s[i][];
}
printf("%.3lf\n",p1-pn);
}
return ;
}
POJ 2151 Check the difficulty of problems的更多相关文章
- POJ 2151 Check the difficulty of problems 概率dp+01背包
题目链接: http://poj.org/problem?id=2151 Check the difficulty of problems Time Limit: 2000MSMemory Limit ...
- POJ 2151 Check the difficulty of problems (动态规划-可能DP)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4522 ...
- [ACM] POJ 2151 Check the difficulty of problems (概率+DP)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 4748 ...
- poj 2151 Check the difficulty of problems(概率dp)
poj double 就得交c++,我交G++错了一次 题目:http://poj.org/problem?id=2151 题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 ...
- POJ 2151 Check the difficulty of problems:概率dp【至少】
题目链接:http://poj.org/problem?id=2151 题意: 一次ACM比赛,有t支队伍,比赛共m道题. 第i支队伍做出第j道题的概率为p[i][j]. 问你所有队伍都至少做出一道, ...
- POJ 2151 Check the difficulty of problems (概率DP)
题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 ,求每队至少解出一题且冠军队至少解出N道题的概率. 析:概率DP,dp[i][j][k] 表示第 i 个队伍,前 j 个题,解出 ...
- POJ 2151 Check the difficulty of problems (概率dp)
题意:给出m.t.n,接着给出t行m列,表示第i个队伍解决第j题的概率. 现在让你求:每个队伍都至少解出1题,且解出题目最多的队伍至少要解出n道题的概率是多少? 思路:求补集. 即所有队伍都解出题目的 ...
- 【POJ】2151 Check the difficulty of problems
http://poj.org/problem?id=2151 题意:T个队伍M条题目,给出每个队伍i的每题能ac的概率p[i][j],求所有队伍至少A掉1题且冠军至少A掉N题的概率(T<=100 ...
- Check the difficulty of problems(POJ 2151)
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5457 ...
随机推荐
- 数据结构算法C语言实现(三十二)--- 9.1静态查找表
一.简述 静态查找表又分为顺序表.有序表.静态树表和索引表.以下只是算法的简单实现及测试,不涉及性能分析. 二.头文件 /** author:zhaoyu date:2016-7-12 */ #inc ...
- jpa和hibernate注解
http://www.objectdb.com/api/java/jpa/JoinColumns 用hibernate和jpa annotation 大概一年多了,今天闲来无事,对他们关联关系元数据写 ...
- django redis VS memcache 区别简介
https://www.v2ex.com/t/142644 http://stackoverflow.com/questions/10558465/memcached-vs-redis 简单来说: r ...
- resultset 对象获取行字段数据时报:java.sql.SQLException: Column 'id' not found.
resultset 对象获取行字段数据时报:java.sql.SQLException: Column 'id' not found. 代码: String sql="SELECT d.co ...
- 《JavaScript权威指南》学习笔记 第一天。
这是零零散散的笔记,作为自己看书打demo的笔记.不足为各位学习,留作自己复习知识点备用. 1.检测对象中某个属性存在不存在: <script> // in 运算符 //不管是对象的自有属 ...
- 《JavaScript权威指南》学习笔记 第二天 下好一盘大棋
前段学习js的时候总是零零散散的,以至于很多东西都模棱两可.时间稍微一久,就容易忘记.最主要的原因是这些东西,原来学的时候就不是太懂,以至于和其他知识无法形成记忆链,所以孤零零的知识特别容易忘记.重温 ...
- NOIp 0904 出题报告
T1 huajitree 纯模拟,把S拆成二进制查一下有多少个1,然后把这个数和N*M求一下gcd,除一下输出就好了.说求期望值可能对新高一不太友好…. //huajitree //2016.8.22 ...
- CDN网络(一)之典型的CND架构与HTTP协议的缓存控制
前言 本人以前在CDN厂商蓝汛就职过一年时间,利用脑子里还残留的一些CDN知识,结合现有的书籍材料,写点东西. what's the CDN CDN(content delivery Network) ...
- 【原】React操作表单
最近的项目中开发中都是用react,其中有用到react去操纵表单.然后自己就在每个表单元素中添加 ref, 然后再像jquery操作dom一样去操纵这个ref, 代码如下: 首先我在每个表单元素那 ...
- Flask-WTF form doesn't have attribute 'validate_on_submit'问题
今天在学习WTF表单的时候遇到了这个问题,在stackoverflow上搜索查到了解决方案 from flask.ext.wtf import Form from wtforms import Tex ...