题意: n和人做m道题, 每俩人做的题数不能相差一题以上.(也就是每n道题分别由n个人完成)   给n个人分别做m道题的概率, 求完成m题的最大期望

$1\le N \le 10$

注意!!! fill dp 的地方!  [0, m]  所以要 m+1 !!

 #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cctype>
#include <cmath>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
typedef long long LL;
typedef long double LD;
#define pi acos(-1.0)
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
typedef pair<int, int> PI;
typedef pair<int, PI> PP;
#ifdef _WIN32
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
//#pragma comment(linker, "/STACK:1024000000,1024000000")
//LL quick(LL a, LL b){LL ans=1;while(b){if(b & 1)ans*=a;a=a*a;b>>=1;}return ans;}
//inline int read(){char ch=' ';int ans=0;while(ch<'0' || ch>'9')ch=getchar();while(ch<='9' && ch>='0'){ans=ans*10+ch-'0';ch=getchar();}return ans;}
//inline void print(LL x){printf(LLD, x);puts("");}
//inline void read(int &x){char c = getchar();while(c < '0') c = getchar();x = c - '0'; c = getchar();while(c >= '0'){x = x * 10 + (c - '0'); c = getchar();}} double mp[][];
double dp[<<][];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int t, ca=;
scanf("%d", &t);
while(t--)
{
int n, m;
scanf("%d%d", &n, &m);
for(int i=;i<n;i++)
for(int j=;j<m;j++)
scanf("%lf", &mp[i][j]);
printf("Case #%d: ", ca++);
for(int i=;i<(<<n);i++)
fill(dp[i], dp[i]+m+, -);
// memset(dp, -1, sizeof(dp));
dp[][]=;
for(int i=;i<m;i++)
for(int s=;s<(<<n);s++)
{
if(dp[s][i]<)
continue ;
for(int j=;j<n;j++)
if(!((<<j) & s)) // 第j个人没做
if(((<<j) | s)==((<<n)-)) // n个人 都做了 则清空 进行下一轮
dp[][i+]=max(dp[][i+], dp[s][i]+mp[j][i]);
else
dp[(<<j) | s][i+]=max(dp[(<<j) | s][i+], dp[s][i]+mp[j][i]);
}
double ans=;
for(int i=;i<=(<<n)-;i++)
ans=max(ans, dp[i][m]);
printf("%.5lf\n", ans);
}
return ;
}

HDOJ 5045

[状压dp]HDU5045 Contest的更多相关文章

  1. 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)-E. Explosion Exploit-概率+状压dp

    2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)-E. Explosion Exploit-概率+状压dp [P ...

  2. Atcoder Regular Contest 093 D - Dark Horse(组合数学+状压 dp)

    Atcoder 题面传送门 & 洛谷题面传送门 常规题,简单写写罢((( 首先 \(1\) 的位置是什么不重要,我们不妨钦定 \(1\) 号选手最初就处在 \(1\) 号位置,最后答案乘个 \ ...

  3. HDUOJ Clear All of Them I 状压DP

    Clear All of Them I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 122768/62768 K (Java/Oth ...

  4. 状压dp Codeforces Beta Round #8 C

    http://codeforces.com/contest/8/problem/C 题目大意:给你一个坐标系,给你一个人的目前的坐标(该坐标也是垃圾桶的坐标),再给你n个垃圾的坐标,这个人要捡完所有的 ...

  5. AC Challenge(状压dp)

    ACM-ICPC 2018 南京赛区网络预赛E: 题目链接https://www.jisuanke.com/contest/1555?view=challenges Dlsj is competing ...

  6. B - 集合选数 (状压DP)

    题目链接:https://cn.vjudge.net/contest/281960#problem/B 题目大意:中文题目 具体思路: 我们通过构造矩阵, x , 3x,9x,27x 2x,6x,18 ...

  7. CCPC-Wannafly Winter Camp Day3 Div1 - 精简改良 - [生成树][状压DP]

    题目链接:https://zhixincode.com/contest/14/problem/D?problem_id=206 样例输入 1  5 5 1 2 1 1 3 1 2 4 1 2 5 1 ...

  8. CH0103最短Hamilton路径 & poj2288 Islands and Brigdes【状压DP】

    虐狗宝典学习笔记: 取出整数\(n\)在二进制表示下的第\(k\)位                                                    \((n >> ...

  9. ZOJ 3777 - Problem Arrangement - [状压DP][第11届浙江省赛B题]

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 Time Limit: 2 Seconds      Me ...

随机推荐

  1. h2database源码浅析:集群

    Clustering / High Availability This database supports a simple clustering / high availability mechan ...

  2. 在知乎回答的一个问题:C#初学者以后往WP开发走,还是往unity3d走?哪个更有前景呢

    问题原文:我是一个C#初学者,想问个问题,我以后是该往WP开发方向走呢还是学习Unity3D往游戏开发,哪个更有前景呢,个人感觉未来几年iOS,WP,Java会三足鼎立,WP现在有潜力,但是U3D现在 ...

  3. iOS 各种控件默认高度

    1.状态栏 状态栏一般高度为20像素,在打手机或者显示消息时会放大到40像素高,注意,两倍高度的状态栏在好像只能在纵向的模式下使用.如下图   用户可以隐藏状态栏,也可以将状态栏设置为灰色,黑色或者半 ...

  4. mysql innodb 数据打捞(四)innodb 簇不连续页扫描提取(试验)

    一,用winhex把正常页有意做成不连续的两部分,把后8K向后移动4K,中间隔开4K,启动第一次扫描; 扫描结果是,没有提取到有效页面,但在输出目录生成两个文件:upper.pages和upper.l ...

  5. Poj/OpenJudge 1042 Gone Fishing

    1.链接地址: http://bailian.openjudge.cn/practice/1042/ http://poj.org/problem?id=1042 2.题目: Gone Fishing ...

  6. the evaluation period for visual studio trial edition has ended的解决方法-转发

    首先献上自己收集的Visual studio 2008序列号: Visual Studio 2008 Professional Edition: XMQ2Y-4T3V6-XJ48Y-D3K2V-6C4 ...

  7. 阿里云ECS服务器被DDoS无解,请问我该何去何从?

    阿里云ECS服务器被DDoS无解,请问我该何去何从?

  8. vs快捷键及常用设置(vs2012版)

    vs快捷键: 1.ctrl+f F是Find的简写,意为查找.在vs工具中按此快捷键,可以查看相关的关键词.比如查找哪些页面引用了某个类等.再配合查找范围(整个解决方案.当前项目.当前文档等),可以快 ...

  9. 更改git bash默认的路径

    更改git bash默认的路径   在打开git bash时,每次都是在C:\Uer路径下,每次都需要先用cd命令转换到自己需要工作的路径(cd  /f/dss).修改打开git bash 时的默认的 ...

  10. Visual C++ 对话框增加菜单栏

    1.添加菜单资源     在resourceview视图中右击选择insert,添加一个菜单资源IDR_MENU1,同时设定好响应的菜单项,例 如:         菜单1               ...