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. 关于stl string find 容易犯的一个错误

    有时候经常会判断一个字符串a中是否有子字符串b,那么有人会调用 string::find这个函数  这个函数返回子字符串首次出现的位置,那么有人会这样写 string str1 = "&qu ...

  2. 关于cookie的清除

    关于cookie的清除     设置cookie时若指定了目录,那么在删除cookie时也必须指定相同的目录,如此才可以删除之前设置的cookie的值!!!!!!!!!

  3. 如何查看postfix的版本

    [root@localhost sasl2]# postconf -d | grep mail_versionmail_version = 2.10.1milter_macro_v = $mail_n ...

  4. linux下vim命令详解

    高级一些的编辑器,都会包含宏功能,vim当然不能缺少了,在vim中使用宏是非常方便的::qx     开始记录宏,并将结果存入寄存器xq     退出记录模式@x     播放记录在x寄存器中的宏命令 ...

  5. C# WPF – 利用“Attached Property” 把 RoutedEvent 接上 ICommand

    本文说明怎样把 DoubleClick 连接至 ICommand.方法很多.推荐使用 Attach Property 方式,因为它能把任何 RoutedEvent 接上任何 ICommand. 之前写 ...

  6. poj 1066 线段相交

    链接:http://poj.org/problem?id=1066 Treasure Hunt Time Limit: 1000MS   Memory Limit: 10000K Total Subm ...

  7. 使用ultramon调整任务栏高度

    取消锁定,调整任务栏的高度为一行图标的高度,然后再锁定即可.为啥程序没有默认设置?

  8. [转载] tmux 使用指南

    原文: https://danielmiessler.com/study/tmux/ tmux的用法和screen类似, 比screen好用一些, 不过需要单独安装

  9. HBase分享会议笔记

    今天参加了一个关于HBase的分享,有一些内容是之前的知识的补充. 之前关于Hadoop家族,包括HBase的内容,可以参考:http://www.cnblogs.com/charlesblc/p/6 ...

  10. Android热修复

    https://github.com/WeMobileDev/article/blob/master/%E5%BE%AE%E4%BF%A1Android%E7%83%AD%E8%A1%A5%E4%B8 ...