7 August
P1021 邮票面值设计
暴搜各面值。
- 剪枝1:面值递增,新面值 \(\in[G_{i-1}+1, n\cdot sum]\). 为什么上界不是 \(n\cdot G_{i-1}+1\) 呢?
- 剪枝2:\(G_1=1\).
dp 求面值最大值。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n, k, f[5005], G[17], ans[17], MAX;
int calc(int dep, int sum) {
memset(f, 0x3f, sizeof f);
f[0]=0;
for (int i=1; i<=dep; ++i) for (int j=G[i]; j<=sum*n; ++j)
f[j]=min(f[j], f[j-G[i]]+1);
for (int i=1; i<=sum*n; ++i) if (f[i]>n) return i-1;
return sum*n;
}
void dfs(int dep, int m, int sum) {
if (dep>k) {
if (MAX<m) {MAX=m; for (int i=1; i<=k; ++i) ans[i]=G[i]; }
return;
}
for (int i=G[dep-1]+1; i<=m+1; ++i) // *1
G[dep]=i, dfs(dep+1, calc(dep, sum+i), sum+i);
}
int main() {
scanf("%d%d", &n, &k);
G[1]=1, dfs(2, n, 1); // *2
for (int i=1; i<=k; ++i) printf("%d ", ans[i]);
printf("\nMAX=%d\n", MAX);
return 0;
}
7 August的更多相关文章
- Monthly Income Report – August 2016
原文链接:https://marcoschwartz.com/monthly-income-report-august-2016/ Every month, I publish a report of ...
- [ZZ]Sign Up for the First-Ever Appium Roadshow on August 20th in New York City
http://sauceio.com/index.php/2014/07/appium-roadshow-nyc/?utm_source=feedly&utm_reader=feedly&am ...
- 浙大月赛ZOJ Monthly, August 2014
Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...
- [转载]ECMA-262 6th Edition / Draft August 24, 2014 Draft ECMAScript Language Specification
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-23.4 Draft Report Errors and Issues at: htt ...
- 135 - ZOJ Monthly, August 2014
135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][ ...
- git -remote: Support for password authentication was removed on August 13, 2021
克隆代码时,报错: Support for password authentication was removed on August 13, 2021. Please use a personal ...
- August 31st 2016 Week 36th Tuesday
A friend without faults will never be found. 没有缺点的朋友是永远找不到的. You can't find a friends without faults ...
- August 30th 2016 Week 36th Tuesday
If you keep on believing, the dreams that you wish will come true. 如果你坚定信念,就能梦想成真. I always believe ...
- August 29th 2016 Week 36th Monday
Every has the capital to dream. 每个人都有做梦的本钱. Your vision, our mission. That is an advertisment of UMo ...
- August 28th 2016 Week 36th Sunday
What doesn't kill you makes you stronger. 那些没有彻底击败你的东西只会让你更强大. Where there is life, there is hope, a ...
随机推荐
- Visual Studio Code配置技巧
Visual Studio Code配置技巧 VS Code是啥 Visual Studio Code(以下简称 VS Code) 是一个免费.开源.跨平台的由微软开发的程序编辑器.它是用 TypeS ...
- .Net core 2.0 利用Attribute获取MVC Action来生成菜单
最近在学习.net core的同时将老师的MVC5项目中的模块搬过来用,其中有一块就是利用Attribute来生成菜单. 一·首先定义Action实体 /// <summary> /// ...
- Hibernate使用时需要注意的几个小问题
今天晚上玩了一下JDBC连接数据库,之后又利用Hibernate进行了数据库的访问,感觉利用Hibernate对数据库访问在文件配置好了之后确实更加简单快捷. 但是在操作的过程中也有一些细节需要注意一 ...
- 2019牛客暑期多校训练营(第一场) - H - XOR - 线性基
https://ac.nowcoder.com/acm/contest/881/H 题意: 给定n个整数,求其中异或和为 \(0\) 的子集的大小的和. 题解思路: 首先转化为每个可以通过异或表示 \ ...
- hdu3664 Permutation Counting(dp)
hdu3664 Permutation Counting 题目传送门 题意: 在一个序列中,如果有k个数满足a[i]>i:那么这个序列的E值为k,问你 在n的全排列中,有多少个排列是恰好是E值为 ...
- weBDrriver API接口方法小记
3.2.1 输入框(text field or textarea) 找到输入框元素:WebElement element = driver.findElement(By.id("passwd ...
- Address already in use : connect
Address already in use : connect 错误以及处理 项目中有过手写并发测试,在长时间的并发测试(超过20秒,美妙超过2000)的情况下出现了以上错误 处理方法如下(抄的) ...
- 2018-7-24-WPF-渲染级别
title author date CreateTime categories WPF 渲染级别 lindexi 2018-07-24 18:46:27 +0800 2018-04-20 16:26: ...
- BJSV-P-003高清智能卡口系统
高清智能卡口系统 捕获率99%,车牌识别率98% ■ 道路安装示意图 ■ 系统结构 ■ 抓拍实例 北京太速科技有限公司在线客服:QQ:448468544 淘宝网站:orihard.tao ...
- gradlew compileDebug --stacktrace -info
gradlew compileDebug --stacktrace -info 在命令行中进入项目的根目录,或者可以在Android studio的Terminal中直接操作也可以,然后敲入一个命令: ...