Contest

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 220    Accepted Submission(s): 88

Problem Description
In the ACM International Collegiate Programming Contest, each team
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

 
Input
The first line of the input is T (1 ≤ T ≤ 20), which stands for the number of test cases you need to solve.

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 .

 
Output
For each test case, print a line “Case #t: ”(without quotes, t means
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.
 
Sample Input
1
2 3
0.6 0.3 0.4
0.3 0.7 0.9
 
Sample Output
Case #1: 2.20000
 
Source
 
 
数位DP:
代码:

#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)的更多相关文章

  1. Bomb HDU - 3555 (数位DP)

    Bomb HDU - 3555 (数位DP) The counter-terrorists found a time bomb in the dust. But this time the terro ...

  2. HDU(3555),数位DP

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others ...

  3. HDU 2089 简单数位dp

    1.HDU 2089  不要62    简单数位dp 2.总结:看了题解才敲出来的,还是好弱.. #include<iostream> #include<cstring> #i ...

  4. HDU(4734),数位DP

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4734 F(x) Time Limit: 1000/500 MS (Java/Others) ...

  5. HDU 3555 Bomb 数位dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3555 Bomb Time Limit: 2000/1000 MS (Java/Others) Mem ...

  6. 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~ ...

  7. HDU 6148 (数位DP)

    ### HDU 6148 题目链接 ### 题目大意: 众所周知,度度熊非常喜欢数字. 它最近发明了一种新的数字:Valley Number,像山谷一样的数字. 当一个数字,从左到右依次看过去数字没有 ...

  8. hdu 3652 【数位dp】

    hdu 3652 题意:求1到n中包含'13'('13'不一定连续)且能被13整除的数的个数. 这是我第一道比较了能看懂的数位dp.定义状态dp[pos][res][sta]表示处理到第pos位,模的 ...

  9. HDU 3652 B-number(数位DP)

    题目链接 学习大神的数位DP模版. #include <iostream> #include <cstdio> #include <cstring> using n ...

  10. HDU 3555 Bomb 数位DP 入门

    给出n,问所有[0,n]区间内的数中,不含有49的数的个数 数位dp,记忆化搜索 dfs(int pos,bool pre,bool flag,bool e) pos:当前要枚举的位置 pre:当前要 ...

随机推荐

  1. CodeForces 432B Football Kit

     Football Kit Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Subm ...

  2. <转>如何改变讨好型人格 | 你根本不需要讨好任何人

    在我过去二十多年的生命里一直是一个“讨好者”. 我总是活在别人对我的期待中,我总是不停的追逐着别人对我的认可,我总是像个卑微的奴才一样去满足别人的需求. 但就和大多数的“讨好者”一样,我们越是寻求别人 ...

  3. jQuery函数attr()和prop()的区别,val()

    [自己总结,详情见下面转录的文章]: attr()用于操作html属性,prop()属性用于操作DOM属性 ①: 很多情况下可以互用 ②:attr()独自适用的情况,自定义的html属性,html属性 ...

  4. git fetch 的简单用法:更新远程代码到本地仓库

    方式一 1. 查看远程仓库 1 2 3 4 5 6 $ git remote -v eoecn https://github.com/eoecn/android-app.git (fetch) eoe ...

  5. 获取DIV与浏览器顶部相聚一定位置之后移动DIV

    获取元素(这里定位元素A)距离顶部的高度,接着设定scroll滚动的事件,比如超过那个高度,把A的位置设定为fixed,小于该高度,修改回relative. 方法一: $(function() {  ...

  6. C# 线程(五):线程池

    From : http://kb.cnblogs.com/page/42531/ 在多线程的程序中,经常会出现两种情况: 一种情况: 应用程序中,线程把大部分的时间花费在等待状态,等待某个事件发生,然 ...

  7. svn使用(服务器端和客户端)

    http://www.cnblogs.com/tugenhua0707/p/3969558.html 网址如上. 很详细.

  8. 2dx中文乱码问题

    我们的代码里面有一个bug 为了跟之前兼容的策划导表工具兼容 导表工具导出的excel全部都是ansi的 为了兼容就只能手动改成utf 8 无bom格式 后来策划嫌烦了 就让在程序段处理这个 研究了好 ...

  9. Nginx基础知识之————什么是 Nginx?

    本课时主要给大家讲解什么是 Nginx 和 Nginx 的功能,Nginx 与其他服务器的性能比较和 Nginx 的优点总结的知识,并结合实例让学员深入理解 Nginx 和 Nginx 的功能以及 N ...

  10. Win7_Wifi热点

    1. 怎样在Win7系统建立并开启Wifi热点 http://jingyan.baidu.com/article/48a42057a03cf7a9242504d0.html 2.