当前位置:网站首页>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];
}
};
边栏推荐
- Pychart connects to the remote server
- php链表创建和遍历
- Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
- 什么是 eRDMA?丨科普漫画图解
- 【题解】Educational Codeforces Round 82
- Fabric.js 上划线、中划线(删除线)、下划线
- STM32库函数进行GPIO初始化
- Large top heap, small top heap and heap sequencing
- 《可供方案开发》口算训练机/数学宝/儿童口算宝/智能数学宝 LCD液晶显示驱动IC-VK1622(LQFP64封装),原厂技术支持
- mongodb的认识
猜你喜欢

富文本编辑器添加矢量公式(MathType for TinyMCE ,可视化添加)

Fabric.js 上划线、中划线(删除线)、下划线

Factal: Unsafe repository is owned by someone else Solution

Teamtalk source code analysis win client

STM32 library function for GPIO initialization

##51单片机实验之简易验证码发生器

【空间&单细胞组学】第1期:单细胞结合空间转录组研究PDAC肿瘤微环境

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

Quick analysis: easy to share the Internet

PHP linked list creation and traversal
随机推荐
Method of creating linked server for cross server data access
taobao. trade. Get (get some information of a single transaction), Taobao store order interface, Taobao oauth2.0 interface, Taobao R2 interface code docking and sharing
It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen
JMeter script parameterization
[apipost] tutorial
复用和分用
Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022
Slashgear shares 2021 life changing technology products, which are somewhat unexpected
##51单片机实验之简易验证码发生器
There is no solution to the decryption error of the remote user 'sa' and the service master password mapped from the remote server 'to the local user' (null) /sa '
ONNX+TensorRT:将预处理操作写入ONNX并完成TRT部署
STM32标准固件库函数名(一)
Implement a server with multi process concurrency
[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment
fatal: unsafe repository is owned by someone else 的解决方法
OpenCV调用USB摄像头的点滴
HMS core machine learning service helps zaful users to shop conveniently
jmeter脚本参数化
threejs的控制器 立方體空間 基本控制器+慣性控制+飛行控制
卷积神经网络(入门)