当前位置:网站首页>LeetCode 2310. 个位数字为 K 的整数之和
LeetCode 2310. 个位数字为 K 的整数之和
2022-07-02 11:26:00 【HumbleFool】
LeetCode 2310. 个位数字为 K 的整数之和
多重背包DP
const int N = 3010;
class Solution {
public:
int f[N][N], v[N]; //前i个体积不超过j的最小个数
int minimumNumbers(int num, int k) {
int n = 0;
for(int i = k; i <= num; i += 10)
n ++,v[n] = i;
memset(f, 0x3f, sizeof f);
f[0][0] = 0;
for(int i = 1; i <= n; i ++)
for(int j = 0; j <= num; j ++)
{
f[i][j] = f[i - 1][j];
if(j >= v[i])
f[i][j] = min(f[i][j], f[i][j - v[i]] + 1); //注意是f[i][j - v[i]] + 1
}
if(f[n][num] == 0x3f3f3f3f)
f[n][num] = -1;
return f[n][num];
}
};
边栏推荐
- Large top heap, small top heap and heap sequencing
- HMS core machine learning service helps zaful users to shop conveniently
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- JMeter script parameterization
- Talk about idempotent design
- 字符串匹配问题
- 1. Editing weapon VIM
- Convolutional neural network (Introduction)
- taobao. trade. memo. Add (add remarks to a transaction) interface, Taobao store flag insertion interface, Taobao order flag insertion API interface, oauth2.0 interface
- threejs的控制器 立方體空間 基本控制器+慣性控制+飛行控制
猜你喜欢

Large top heap, small top heap and heap sequencing

报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.

A white hole formed by antineutrons produced by particle accelerators

Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?

一张图彻底掌握prototype、__proto__、constructor之前的关系(JS原型、原型链)

buuctf-pwn write-ups (7)

Tencent cloud tstor unified storage passed the evaluation of the first batch of basic file storage capabilities of the ICT Institute

fatal: unsafe repository is owned by someone else 的解决方法

JMeter script parameterization

Reuse and distribution
随机推荐
一张图彻底掌握prototype、__proto__、constructor之前的关系(JS原型、原型链)
篇9:XShell免费版安装
STM32标准固件库函数名(一)
天猫商品详情接口(APP,H5端)
Socket and socket address
info [email protected]: The platform “win32“ is incompatible with this module.
Bit by bit of OpenCV calling USB camera
《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
taobao.trades.sold.get-查询卖家已卖出的交易数据(根据创建时间),淘宝店铺卖出订单查询API接口,淘宝R2接口,淘宝oAuth2.0交易接口代码分享
buuctf-pwn write-ups (7)
Design and implementation of car query system based on php+mysql
NLA自然语言分析实现数据分析零门槛
电脑怎么设置扬声器播放麦克风的声音
卷积神经网络(入门)
Delete element (with transition animation)
检查密码
Uniapp automated test learning
4、数组指针和指针数组
Use of freemaker
3、函数指针和指针函数