[poj2151]Check the difficulty of problems概率dp
解题关键:主要就是概率的推导以及至少的转化,至少的转化是需要有前提条件的。
转移方程:$dp[i][j][k] = dp[i][j - 1][k - 1]*p + dp[i][j - 1][k]*(1 - p)$ 其中$dp[i][j][k]$表示第$i$个人前j题恰好ac了$k$题.然后用前缀和处理一下最后的结果。
每队至少AC一题 反向考虑,用1-每队没A题的概率,再用乘法原理结合一下。
冠军队至少AC$n-1$题,也就是存在一支队伍AC数>=n-1,依然反向考虑,不过是在每队AC至少一题的条件下,从而求出每队AC数>=1,<n-1,再用前面的概率减去此概率即可。
复杂度:1000*30*30
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
double p[][],dp[][][],s[][];
int main(){
int m,t,n;
ios::sync_with_stdio();
while(cin>>m>>t>>n&&(n||m||t)){
for(int i=;i<=t;i++){
for(int j=;j<=m;j++){
cin>>p[i][j];
}
} for(int i=;i<=t;i++){
dp[i][][]=;
for(int j=;j<=m;j++){
dp[i][j][]=dp[i][j-][]*(-p[i][j]);//类似杨辉三角的推法,注意按照怎样的顺序才能推出全部
}
} for(int i=;i<=t;i++){
for(int j=;j<=m;j++){
for(int k=;k<=j;k++){//注意控制变量范围,保证有意义
dp[i][j][k]=dp[i][j-][k-]*p[i][j]+dp[i][j-][k]*(-p[i][j]);
}
}
}
for(int i=;i<=t;i++){
for(int j=;j<=m;j++){
s[i][j]=s[i][j-]+dp[i][m][j];
}
} double ans1=1.0,ans2=1.0,t1;
for(int i=;i<=t;i++) t1=-s[i][],ans1*=t1;
for(int i=;i<=t;i++) t1=s[i][n-]-s[i][],ans2*=t1;
printf("%.3f\n",ans1-ans2); }
}
[poj2151]Check the difficulty of problems概率dp的更多相关文章
- [POJ2151]Check the difficulty of problems (概率dp)
题目链接:http://poj.org/problem?id=2151 题目大意:有M个题目,T支队伍,第i个队伍做出第j个题目的概率为Pij,问每个队伍都至少做出1个题并且至少有一个队伍做出N题的概 ...
- POJ 2151 Check the difficulty of problems 概率dp+01背包
题目链接: http://poj.org/problem?id=2151 Check the difficulty of problems Time Limit: 2000MSMemory Limit ...
- [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)
题意:ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 ,求每队至少解出一题且冠军队至少解出N道题的概率. 析:概率DP,dp[i][j][k] 表示第 i 个队伍,前 j 个题,解出 ...
- POJ2157 Check the difficulty of problems 概率DP
http://poj.org/problem?id=2151 题意 :t个队伍m道题,i队写对j题的概率为pij.冠军是解题数超过n的解题数最多的队伍之一,求满足有冠军且其他队伍解题数都大于等于1 ...
- POJ2151Check the difficulty of problems 概率DP
概率DP,还是有点恶心的哈,这道题目真是绕,问你T个队伍.m个题目.每一个队伍做出哪道题的概率都给了.冠军队伍至少也解除n道题目,全部队伍都要出题,问你概率为多少? 一開始感觉是个二维的,然后推啊推啊 ...
- POJ-2151 Check the difficulty of problems---概率DP好题
题目链接: https://vjudge.net/problem/POJ-2151 题目大意: ACM比赛中,共M道题,T个队,pij表示第i队解出第j题的概率 问 每队至少解出一题且冠军队至少解出N ...
- poj 2151Check the difficulty of problems<概率DP>
链接:http://poj.org/problem?id=2151 题意:一场比赛有 T 支队伍,共 M 道题, 给出每支队伍能解出各题的概率~ 求 :冠军至少做出 N 题且每队至少做出一题的概率~ ...
- 【POJ】2151:Check the difficulty of problems【概率DP】
Check the difficulty of problems Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8903 ...
随机推荐
- H2 database 操作操作内存表
本例开发工具为 NetBeans,使用b2前提安装jdk. 第一步:在官网下载驱动包 :http://www.h2database.com ,本例版本为: h2-1.4.192.jar 第二步:安装开 ...
- Android中RelativeLayout各个属性及其含义
android:layout_above="@id/xxx" --将控件置于给定ID控件之上android:layout_below="@id/xxx" - ...
- [URAL-1517][求两个字符串的最长公共子串]
Freedom of Choice URAL - 1517 Background Before Albanian people could bear with the freedom of speec ...
- Python中的staticmethod和classmethod
谈谈Python中的staticmethod和classmethod 首先值得说明的是staticmethod和classmethod都是python中定义的装饰器,用的时候需要在前面加@ 即@sta ...
- apache 301重定向到带www的二级域名
Options +FollowSymlinks RewriteEngine on rewritecond %{http_host} ^nlike.cn [nc] rewriterule ^(.*)$ ...
- HNOI2016
本蒟蒻表示终于$AC$了$HNOI2016$的六道毒瘤题... 高兴! 附上各个题的题解: $DAY1$: $T1$: BZOJ4537: [Hnoi2016]最小公倍数 $T2$: BZOJ4538 ...
- memcache-session-manager(flexjson)
MSM项目FlexJson序列化参考文档. 序号(步骤) 需求描述 jar包列表: spymemcached-2.11.1.jar memcached-session-manager-tc8-1.8. ...
- MySQL修改配置 区分大小写
在使用mysql的时候,数据库名,表名,字段名等有大小写的区分,这个可以通过配置文件设置.如果设置了严格区分大小写,在访问表的时候没有注意到表名的大小写,将会报出表不存在的错误.下面是修改配置文件: ...
- spring-boot3代码
App.java package com.kfit; import org.springframework.boot.SpringApplication; import org.springframe ...
- 3D 图片播放焦点图插件Adaptor
在线演示 本地下载