当前位置:网站首页>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];
}
};
边栏推荐
- 1、编辑利器vim
- Check password
- Available solution development oral arithmetic training machine / math treasure / children's oral arithmetic treasure / intelligent math treasure LCD LCD driver ic-vk1622 (lqfp64 package), original te
- 《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
- threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
- 【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境
- taobao. logistics. dummy. Send (no logistics delivery processing) interface, Taobao store delivery API interface, Taobao order delivery interface, Taobao R2 interface, Taobao oau2.0 interface
- PTA题库 ===>复数四则运算,一帮一,考试座位号(7-73)
- Obsidian installs third-party plug-ins - unable to load plug-ins
- 一张图彻底掌握prototype、__proto__、constructor之前的关系(JS原型、原型链)
猜你喜欢
mathML转latex
广州市应急管理局发布7月高温高湿化工安全提醒
YoloV6训练:训练自己数据集遇到的各种问题
taobao. trade. memo. Add (add remarks to a transaction) interface, Taobao store flag insertion interface, Taobao order flag insertion API interface, oauth2.0 interface
Li Chuang EDA learning notes 15: draw border or import border (DXF file)
Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)
QT new project
Wechat applet uses towxml to display formula
Development and design of animation surrounding mall sales website based on php+mysql
Yolov3 & yolov5 output result description
随机推荐
A white hole formed by antineutrons produced by particle accelerators
Fabric.js 缩放画布
Actual combat sharing of shutter screen acquisition
STM32标准固件库函数名(一)
MQ tutorial | exchange (switch)
Fabric.js 上划线、中划线(删除线)、下划线
OpenCV调用USB摄像头的点滴
Uniapp automated test learning
Basic knowledge of QT original code
Fabric. JS dynamically set font size
Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
JMeter script parameterization
跨服务器数据访问的创建链接服务器方法
tmall. product. schema. Get (product information acquisition schema acquisition), Taobao store upload commodity API interface, Taobao commodity publishing interface, Taobao commodity upload API interf
Socket and socket address
使用mathtype编辑公式,复制粘贴时设置成仅包含mathjax语法的公式
The use of TestNG, the testing framework (II): the use of TestNG XML
Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
Advanced usage of C language -- function pointer: callback function; Conversion table
HMS core machine learning service helps zaful users to shop conveniently