题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6092

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 1e4 + ;
int b[maxn] , dp[maxn] , n , m;
int main() {
int t;
scanf("%d", &t);
while(t--) {
scanf("%d%d" , &n , &m);
for (int i = ; i <= m; i++) {
scanf("%d" , &b[i]);
dp[i] = ;
}
dp[] = ;
int count = ;
for (int i = ; i <= m; i++) {
while (dp[i] < b[i]) {
count++;
if(count != n) printf("%d " , i);
else printf("%d\n" , i);
for (int j = m ; j >= i ; j--) {
dp[j] += dp[j - i];
}
}
}
}
return ;
}

题解:就是一道多重背包,每次有优先拿最小的来更新看代码就很好理解了。

最新文章

  1. oracle 查询月份差
  2. 斐波那契堆(一)之 图文解析 和 C语言的实现
  3. list集合练习一
  4. HibernateSessionFactory类的主要方法
  5. python网络编程(进程与多线程)
  6. C++——函数重载
  7. UNIX网络编程——利用ARP和ICMP协议解释ping命令
  8. 究竟谁在绑架中国的4G政策?
  9. [Abp vNext 源码分析] - 3. 依赖注入与拦截器
  10. 手机CPU架构体系分类及各大厂商
  11. TF:利用TF的train.Saver将训练好的variables(W、b)保存到指定的index、meda文件—Jason niu
  12. P4312 [COCI 2009] OTOCI / 极地旅行社
  13. 使用Zookeeper命令的简单操作步骤
  14. 静态布局、自适应布局、流式布局、响应式布局、弹性布局简析、BFC
  15. python异常处理方法
  16. sencha touch 在线实战培训 第一期 第七节
  17. SQL Server提取字段中的所有数字
  18. HDU 4952 Poor Mitsui(贪心)
  19. R语言绘图边框的单位
  20. SQL:存储过程

热门文章

  1. Android Studio项目/Flutter 案例中Gradle报错通用解决方案(包括Unable to tunnel through proxy问题)
  2. spark shuffle写操作三部曲之UnsafeShuffleWriter
  3. Spark 系列(七)—— 基于 ZooKeeper 搭建 Spark 高可用集群
  4. jQuery发送Ajax请求以及出现的问题
  5. k8s学习笔记
  6. ZooKeeper系列(一)—— ZooKeeper 简介及核心概念
  7. vs 中本地 git 的基本使用
  8. UI 组件 | Button
  9. odoo添加顶部按钮实现自定义方法
  10. 自由变形技术(Free-Form Deformation)