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:当前要 ...
随机推荐
- 【转载】CMake 简介和 CMake 模板
转载自我的博客: CMake 简介和 CMake 模板 . 如果你用 Linux 操作系统,使用 cmake 会简单很多,可以参考一个很好的教程: CMake 入门实战 | HaHack .如果你用 ...
- jquery之insertBefore(),insertAfter(),prependTo(),appendTo()用法详解
导航: 1,insertBefore(),insertAfter(),prependTo(),appendTo()这四个函数用法几乎一样 2, 与之相对的有四个函数:Before(),After(), ...
- Datatypes In SQLite Version 3
http://www.sqlite.org/datatype3.html http://stackoverflow.com/questions/7337882/what-is-the-differen ...
- Shifting List Item Values From One List To Another In Oracle Forms
Suppose you have two T-List items in form and you want to shift element values from one list to ano ...
- MS16-016 提权EXP
测试环境 win7 32 位未打任何补丁 1.使用net user 指令 测试得到结果没有权限新建用户 2.查看系统用户 3.复制EXP到win7 下 使用命令打开 添加新用户再查看用户列表
- 【CC评网】2013.第44周 把握每天的第一个小时
[CC评网]2013.第44周 把握每天的第一个小时 更简单的格式 终于投入到markdown的怀抱.让博客的写作回归到内容本身,同时也能保证阅读的良好体验:如果有心情,写个js,提取h3 h2标题组 ...
- 初识Oracle
登录时无法登陆: 无监听程序 ———>启动服务OracleXETNListener 监听程序当前无法识别连接描述中的请求服务————>重启服务 OracleServic ...
- iOS - Widget 小部件
1.Widget iOS extension 的出现,方便了用户查看应用的服务,比如用户可以在 Today 的 widgets 中查看应用的简略信息,然后点击进入相关的应用界面. 2.添加 Widge ...
- [转载] linux 程序运行过程中替换文件
今天被朋友问及“Linux下可以替换运行中的程序么?”,以前依稀记得Linux下是可以的(而Windows就不让),于是随口答道“OK”.结果朋友发来一个执行结果:(test正在运行中)# cp te ...
- [转载] 深入 nginx 架构
原文: http://www.cnbeta.com/articles/402709.htm 了解 nginx 架构帮助我们学习如何开发高性能 web 服务. 为了更好地理解设计,你需要了解NGINX是 ...