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 ...
随机推荐
- EasyUI DataGrid View
http://www.jeasyui.com/easyui/datagrid-detailview.js 前提一定要引入:datagrid-detailview.js主要是三个属性和普通的datgag ...
- 安装VC6提示找不到ACME时的解决办法
将安装程序COPY到电脑上1.打开setupwiz.ini,把"acme=acmboot.exe"改为"=acmsetup.exe";2.STF=setup/v ...
- oracle优化原则(二)
SQL优化原则 二.SQL语句编写注意问题 www.2cto.com 下面就某些SQL语句的where子句编写中需要注意的问题作详细介绍.在这些where子句中,即使某些列存在索引,但是由于编写了劣质 ...
- 436. Find Right Interval ——本质:查找题目,因此二分!
Given a set of intervals, for each of the interval i, check if there exists an interval j whose star ...
- Spring MVC Controller中解析GET方式的中文参数会乱码的问题(tomcat如何解码)
Spring MVC Controller中解析GET方式的中文参数会乱码的问题 问题描述 在工作上使用突然出现从get获取中文参数乱码(新装机器,tomcat重新下载和配置),查了半天终于找到解决办 ...
- eclipse关联tomcat并且部署java web应用程序
http://www.ibm.com/developerworks/cn/opensource/os-eclipse-tomcat/
- NLTk
1.python的nltk中文使用和学习资料汇总帮你入门提高 http://blog.csdn.net/huyoo/article/details/12188573
- C-union的使用
union有两个作用: 1,节约空间,如果一个struct存在两个互斥的变量,则可以把这个struct变成union 2,将同一个内存作为多种解释 代码: #include <iostream& ...
- wp8.1 C#技巧: Data和ViewModel类编写
在Data.cs namespace PicApp { [DataContract] class DataItem : PropertyChangeNotification { public even ...
- bzoj 3529 数表 莫比乌斯反演+树状数组
题目大意: 有一张N×m的数表,其第i行第j列(1 < =i < =礼,1 < =j < =m)的数值为能同时整除i和j的所有自然数之和.给定a,计算数表中不大于a的数之和. ...