hdu 6092 Rikka with Subset(多重背包)
2024-08-28 20:08:54
题目链接: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 ;
}
题解:就是一道多重背包,每次有优先拿最小的来更新看代码就很好理解了。
最新文章
- oracle 查询月份差
- 斐波那契堆(一)之 图文解析 和 C语言的实现
- list集合练习一
- HibernateSessionFactory类的主要方法
- python网络编程(进程与多线程)
- C++——函数重载
- UNIX网络编程——利用ARP和ICMP协议解释ping命令
- 究竟谁在绑架中国的4G政策?
- [Abp vNext 源码分析] - 3. 依赖注入与拦截器
- 手机CPU架构体系分类及各大厂商
- TF:利用TF的train.Saver将训练好的variables(W、b)保存到指定的index、meda文件—Jason niu
- P4312 [COCI 2009] OTOCI / 极地旅行社
- 使用Zookeeper命令的简单操作步骤
- 静态布局、自适应布局、流式布局、响应式布局、弹性布局简析、BFC
- python异常处理方法
- sencha touch 在线实战培训 第一期 第七节
- SQL Server提取字段中的所有数字
- HDU 4952 Poor Mitsui(贪心)
- R语言绘图边框的单位
- SQL:存储过程
热门文章
- Android Studio项目/Flutter 案例中Gradle报错通用解决方案(包括Unable to tunnel through proxy问题)
- spark shuffle写操作三部曲之UnsafeShuffleWriter
- Spark 系列(七)—— 基于 ZooKeeper 搭建 Spark 高可用集群
- jQuery发送Ajax请求以及出现的问题
- k8s学习笔记
- ZooKeeper系列(一)—— ZooKeeper 简介及核心概念
- vs 中本地 git 的基本使用
- UI 组件 | Button
- odoo添加顶部按钮实现自定义方法
- 自由变形技术(Free-Form Deformation)