hdu----(5045)Contest(数位dp)
Contest
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 220 Accepted Submission(s): 88
consist of three students. And the teams are given 5 hours to solve
between 8 and 12 programming problems.
On Mars, there is
programming contest, too. Each team consist of N students. The teams are
given M hours to solve M programming problems. Each team can use only
one computer, but they can’t cooperate to solve a problem. At the
beginning of the ith hour, they will get the ith programming problem.
They must choose a student to solve this problem and others go out to
have a rest. The chosen student will spend an hour time to program this
problem. At the end of this hour, he must submit his program. This
program is then run on test data and can’t modify any more.
Now, you have to help a team to find a strategy to maximize the expected number of correctly solved problems.
For each problem, each student has a certain probability that correct solve. If the ith student solve the jth problem, the probability of correct solve is Pij .
At any time, the different between any two students’ programming time
is not more than 1 hour. For example, if there are 3 students and there
are 5 problems. The strategy {1,2,3,1,2}, {1,3,2,2,3} or {2,1,3,3,1}
are all legal. But {1,1,3,2,3},{3,1,3,1,2} and {1,2,3,1,1} are all
illegal.
You should find a strategy to maximize the expected number of correctly solved problems, if you have know all probability
The first line of each case contains two integers N ,M (1 ≤ N ≤ 10,1 ≤
M ≤ 1000),denoting the number of students and programming problem,
respectively.
The next N lines, each lines contains M real numbers between 0 and 1 , the jth number in the ith line is Pij .
the index of the test case) at the beginning. Then a single real number
means the maximal expected number of correctly solved problems if this
team follow the best strategy, to five digits after the decimal point.
Look at the output for sample input for details.
2 3
0.6 0.3 0.4
0.3 0.7 0.9
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
const int maxn=1050l
double dp[maxn][maxn];
double a[][maxn];
int main(){
int cas,n,m;
scanf("%d",&cas);
for(int w=;w<=cas;w++){
scanf("%d%d",&n,&m);
for(int i=;i<=;i++){
for(int j=;j<=m;j++){
dp[i][j]=-;
}
}
dp[][]=0.0;
for(int i=;i<=n;i++){
for(int j=;j<=m;j++){
scanf("%lf",&a[i][j]);
}
}
int tol=(<<n)-;
double ans=0.0;
for(int j=;j<=m;j++){
for(int i=;i<tol;i++){
for(int k=;k<=n;k++){
int tt=<<(k-);
if(dp[i][j-]<)continue; if(tt&i)continue;
int pos=i|tt;
if(pos==tol)pos=;
dp[pos][j]=max(dp[pos][j],dp[i][j-]+a[k][j]);
if(j==m)ans=max(ans,dp[pos][j]);
}
}
}
printf("Case #%d: %.5lf\n",w,ans);
}
return ;
}
hdu----(5045)Contest(数位dp)的更多相关文章
- Bomb HDU - 3555 (数位DP)
Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terro ...
- HDU(3555),数位DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others ...
- HDU 2089 简单数位dp
1.HDU 2089 不要62 简单数位dp 2.总结:看了题解才敲出来的,还是好弱.. #include<iostream> #include<cstring> #i ...
- HDU(4734),数位DP
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4734 F(x) Time Limit: 1000/500 MS (Java/Others) ...
- HDU 3555 Bomb 数位dp
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...
- Hdu 4734 【数位DP】.cpp
题意: 我们定义十进制数x的权值为f(x) = a(n)*2^(n-1)+a(n-1)*2(n-2)+...a(2)*2+a(1)*1,a(i)表示十进制数x中第i位的数字. 题目给出a,b,求出0~ ...
- HDU 6148 (数位DP)
### HDU 6148 题目链接 ### 题目大意: 众所周知,度度熊非常喜欢数字. 它最近发明了一种新的数字:Valley Number,像山谷一样的数字. 当一个数字,从左到右依次看过去数字没有 ...
- hdu 3652 【数位dp】
hdu 3652 题意:求1到n中包含'13'('13'不一定连续)且能被13整除的数的个数. 这是我第一道比较了能看懂的数位dp.定义状态dp[pos][res][sta]表示处理到第pos位,模的 ...
- HDU 3652 B-number(数位DP)
题目链接 学习大神的数位DP模版. #include <iostream> #include <cstdio> #include <cstring> using n ...
- HDU 3555 Bomb 数位DP 入门
给出n,问所有[0,n]区间内的数中,不含有49的数的个数 数位dp,记忆化搜索 dfs(int pos,bool pre,bool flag,bool e) pos:当前要枚举的位置 pre:当前要 ...
随机推荐
- excel在一个图表内,显示折线图和柱状图
折线图和柱状图,在同一个图表中拆分显示 一个图,设置主坐标轴 另外一个图,设置次坐标轴 拆分,通过调整纵坐标的最小值和最大值来实现 关于图表的标题,选中图表,选择布局,然后图表 ...
- Refresh / Updating a form screen in Oracle D2k Forms 6i
Refresh / Updating a form screen in Oracle D2k Forms 6i ProblemYou want to show number of records pr ...
- Virtualenv: 一个Python环境管理工具(windown版本)
1.安装virtualenv 在安装virtualenv之前,我们需要安装至少有一个版本的python:因为virtualenv是python的一个第三方模块,必须基于python环境才能安装: 如果 ...
- 在服务器端如何提取checkbox提交的数据?
HttpServeletRequest 单个字符串,getParameters() 多个字符串,getParametersValues(),返回一个数组,需要提前定义一个数组
- C#开发ActiveX控件及指纹采集
最近做一个指纹采集和比对的功能,因为公司整个项目是WEB类型的,所以指纹采集的模块要嵌套在网页中,那只有用ActiveX了,以下是一些操作及效果,做个笔记! 新建用户控件,编写CS代码,如下: usi ...
- 线程入门之join方法
package com.thread; /** * <join:将某线程加入进来,相当于方法调用,也叫合并某个线程> * <功能详细描述> * * @author 95Yang ...
- iOS - UIViewController
前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIViewController : UIResponder <NSCoding, UIAppearanceC ...
- c++ IO的继承结构
#include <stdio.h> #include <iostream>//cin,cout #include <sstream>//ss transfer. ...
- mysql 中文字段排序( 按拼音首字母排序) 的查询语句
在处理使用Mysql时,数据表采用utf8字符集,使用中发现中文不能直接按照拼音排序 如果数据表tbl的某字段name的字符编码是latin1_swedish_ci select * from `tb ...
- Python学习笔记3—字符串
原始字符串 使用\转义或者r,这种方法在网站设置网站目录结构的时候非常管用. >>> dos="c:\news" >>> print dos c ...