题意:

有n个学生,m道题,给出每个同学解出m个问题的概率,在解题过程中每个学生的解题数的差不大于1,求最大能解出题目数的期望

分析:

n很小,知道用状压,但是比赛没做出来(脑子太死了,有一个限制条件在解题过程中每个学生的解题数的差不大于1,哎,关键在这句话,那就是说,在解题过程中必须先是每人解出一道题目,才能继续解题,那就是状态全部是1时处理成全部是0)

dp[i][j]表示前i个题目解题情况是j时的最大值。

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <string>
#include <cctype>
#include <complex>
#include <cassert>
#include <utility>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int,int> PII;
typedef long long ll;
#define lson l,m,rt<<1
#define pi acos(-1.0)
#define rson m+1,r,rt<<11
#define All 1,N,1
#define read freopen("in.txt", "r", stdin)
const ll INFll = 0x3f3f3f3f3f3f3f3fLL;
const int INF= 0x7ffffff;
const int mod = ;
double dp[][],p[][];
int n,m;
double solve(){
int cas=(<<n)-;
for(int i=;i<=m;++i)
for(int j=;j<=cas;++j)
dp[i][j]=-1.0;
dp[][]=0.0;
for(int i=;i<m;++i)
for(int j=;j<=cas;++j){
if(dp[i][j]<)continue;//未到达的状态
for(int k=;k<n;++k){
int tmp;
if(!(j&(<<k))){
tmp=(j|(<<k));
if(tmp==cas)tmp=;
dp[i+][tmp]=max(dp[i+][tmp],dp[i][j]+p[k][i]);
}
}
}
double maxv=-1.0;
for(int i=;i<=cas;++i)
maxv=max(maxv,dp[m][i]);
return maxv;
}
int main()
{
int t,num=;
scanf("%d",&t);
while(t--){
scanf("%d%d",&n,&m);
for(int i=;i<n;++i)
for(int j=;j<m;++j)
scanf("%lf",&p[i][j]);
//solve();
printf("Case #%d: %.5lf\n",++num,solve());
}
return ;
}

HDU5045-Contest(状压dp)的更多相关文章

  1. HDU 5045 Contest(状压DP)

    Problem Description In the ACM International Collegiate Programming Contest, each team consist of th ...

  2. 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 ...

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

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

  4. 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 ...

  5. 状压dp Codeforces Beta Round #8 C

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

  6. AC Challenge(状压dp)

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

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

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

  8. 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 ...

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

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

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

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

随机推荐

  1. iptables 代理设置

    代理: 开启转发:echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -s 192.168.1.0/24 ...

  2. 用Delphi创建服务程序

    用Delphi创建服务程序 日期:2005年11月29日 作者:sunmohe 人气: 3154 查看:[大字体 中字体 小字体] Windows 2000/XP和2003等支持一种叫做"服 ...

  3. 【memcache缓存专题(3)】PHP-memcache扩展的安装以及使用

    安装PHP-memcache扩展和安装其他PHP扩展的步骤是一样的. 安装 step 1:搜索下载扩展 http://pecl.php.net/package/memcache step 2: gzi ...

  4. linux上应用程序的执行机制

    linux上应用程序的执行机制 执行文件是如何在shell中被"执行"的.本文中尽可能少用一些源码,免得太过于无 聊,主要讲清这个过程,感兴趣的同学可以去查看相应的源码了解更多的信 ...

  5. ubuntu中一些软件的命令安装及设置

    ssh: sudo apt-get install openssh-server sudo apt-get install openssh-client

  6. kmalloc/kfree,vmalloc/vfree函数用法和区别

    http://blog.csdn.net/tigerjibo/article/details/6412881 kmalloc/kfree,vmalloc/vfree函数用法和区别 1.kmalloc ...

  7. Lua表的构造及遍历

    关于lua中的table,主要的困惑来自于table既可以当array用又可以当record用,有时候就会混淆不清. lua中的table貌似是用map来实现的,array是语法糖,一种特例.下面是l ...

  8. 门面(Facade)模式(转)

    转载:http://www.cnblogs.com/skywang/articles/1375447.html 外部与一个子系统的通信必须通过一个统一的门面(Facade)对象进行,这就是门面模式. ...

  9. jQuery插件开发(转)

    jQuery插件开发 - 其实很简单 [前言]jQuery已经被广泛使用,凭借其简洁的API,对DOM强大的操控性,易扩展性越来越受到web开发人员的喜爱,我在社区也发布了很多的jQuery插件,经常 ...

  10. html 表单笔记

         表单 表单中主要包括下列元素: button——普通按钮radio ——单选按钮checkbox——复选框select ——下拉式菜单text ——单行文本框textarea——多行文本框s ...