HDU 2291
http://acm.hdu.edu.cn/showproblem.php?pid=2291
读题读的烦死了,今天果真不适合做题
题意:给两个n*n的矩阵,第一个代表一个人战胜一个人可以得到的经验值,第二个代表一个人战胜另一个人可以得到的分数,然后n个数,代表n个人的初始经验值,只有经验值大于对手才可以取胜,问第一个人最后取得的最大分数
n只有13,状压dp随便搞一下
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std ; int dp[<<];
int e[],r[],s[],n; int exp(int x){
int st=;
int res=s[];
for(int i=;i<n-;i++){
if((x>>i)&){
res+=e[st];
}
st++;
}
return res;
} int main(){
int T;
scanf("%d",&T);
while(T--){
scanf("%d",&n);
for(int i=;i<n*n;i++)
scanf("%d",&e[i]);
for(int i=;i<n*n;i++)
scanf("%d",&r[i]);
for(int i=;i<n;i++)
scanf("%d",&s[i]);
memset(dp,,sizeof(dp));
for(int i=;i<(<<(n-));i++){
for(int j=;j<n-;j++){
if(i&(<<j)){
if(exp(i^(<<j))>s[j+]){
dp[i]=max(dp[i],dp[i^(<<j)]+r[j+]);
}
}
}
}
printf("%d\n",dp[(<<(n-))-]);
}
return ;
}
HDU 2291的更多相关文章
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- hdu 3191 How Many Paths Are There (次短路径数)
How Many Paths Are There Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
随机推荐
- FileUpload上传与下载
后台代码: public string connstr = "server=128.1.3.113;database=test;uid=sa;pwd=pass"; protecte ...
- linux shell中,单引号、 双引号,反引号(``),$()的区别
一.单引号和双引号 首先,单引号和双引号,都是为了解决中间有空格的问题. 空格在linux中时作为一个很典型的分隔符,比如 string1=this is a string,这样执行会报错.为了避免这 ...
- HTTP方法简介
GET 请求获取资源 HEAD 与GET类似,但服务器只返回首部 PUT 与GET相反,向服务器写入文档 POST 向服务器输入数据,通常使用HTML表单形式 TRACE 客户端发起请求时,需要穿越防 ...
- mysql用户备份与修复
1.修复表repair table tb1 [use frm]; #红色部分代表可添加也可不加, 2.show variables like '%timeout%'; #查询关键字 3. 更改数据, ...
- java正则表达式之java小爬虫
这个java小爬虫, 功能很简单,只有一个,抓取网上的邮箱.用到了javaI/O,正则表达式. public static void main(String[] args) throws IOExce ...
- C# 子窗体点击按钮产生的新子窗体放在父窗体里
情景展示: 父窗体Form1,左边是按钮,右边是panel(放置子窗体) 父窗体点击按钮,在panel显示第一个子窗体AA, AA有个按钮,点击按钮,是第二个子窗体ZZ, 怎样将AA的子窗体ZZ也显示 ...
- C# DES加密
需要引用名称空间 using System; using System.Text; using System.Security.Cryptography; using System.IO; 具体代码: ...
- jpcap
1.System.out.println( System.getProperty("java.library.path")); 2.将jpcap.dll放到上边打印的路径中
- IBInspectable / IBDesignable
无论陈词滥调多少次,比起一个需要我们记住并且输入什么的界面来说,如果替换成我们能够看见并可控制的界面的话将会是巨大的进步. Xcode 6 提供了这样一个替代,在旧技术上建立新的互动.在设计项目的时候 ...
- 【转发】linux文件系统变为只读的修复
详细解决方法:http://smartmontools.sourceforge.net/badblockhowto.html 相关问题,更换硬盘:http://blog.chinaunix.net/u ...