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 ...
随机推荐
- HTML--JS 随机背景色
<html> <head> <title>背景随机变色</title> <script type="text/javascript&qu ...
- Run Your Tensorflow Deep Learning Models on Google AI
People commonly tend to put much effort on hyperparameter tuning and training while using Tensoflow& ...
- 《JAVA设计模式》之代理模式(Proxy)
在阎宏博士的<JAVA与模式>一书中开头是这样描述代理(Proxy)模式的: 代理模式是对象的结构模式.代理模式给某一个对象提供一个代理对象,并由代理对象控制对原对象的引用. 代理模式的结 ...
- redis 哨兵配置文件解读sentinel.conf
# Example sentinel.conf # port <sentinel-port>port 8001 # 守护进程模式daemonize yes # 指明日志文件名logfile ...
- mysql (mariadb)表结构添加修改删除方法总结
1,添加表字段 alter table table1 add ptel varchar(100) not Null; alter table table1 add id int unsigned no ...
- Spring Boot 项目 Maven 配置
在配置基于Maven的Spring Boot项目的过程中,打包运行出现了一系列错误. 比如: mvn 中没有主清单属性.java.lang.NoClassDefFoundError: org/spri ...
- Nginx学习总结:常用module(二)
斜体下划线,表示建议采用默认配置,无需显式的配置 一.ngx_core_module 1.accept_mutex [on | off] 上下文:events 默认为“on”,在wor ...
- K8S存储相关yaml
一.ConfigMap 1.使用目录创建 vim game.properties vim ui.properties 在一个文件夹下创建两个文件,通过以下命令创建 kubectl create con ...
- python常用函数 N
nlargest(int , iterable,key) 查找最大的n个元素. 例子: 还支持传入key进行复杂元素比较:如:nlargest (n, list,key=lambda a:a[b]). ...
- lvm相关知识
参考资料: 1.https://www.cnblogs.com/mchina/p/linux-centos-logical-volume-manager-lvm.html#top