当前位置:网站首页>剑指 Offer 14- I. 剪绳子
剑指 Offer 14- I. 剪绳子
2022-08-02 02:45:00 【henujolly】
class Solution {
public:
int cuttingRope(int n) {
vector <int> dp(n + 1);
for (int i = 2; i <= n; i++) {
int curMax = 0;
for (int j = 1; j < i; j++) {
curMax = max(curMax, max(j * (i - j), j * dp[i - j]));
}
dp[i] = curMax;
}
return dp[n];
}
};
边栏推荐
- 永磁同步电机36问(三)——SVPWM代码实现
- What to study after the PMP exam?The soft exam ahead is waiting for you~
- 机器人领域期刊会议汇总
- Power button 1374. Generate each character string is an odd number
- 局部敏感哈希:如何在常数时间内搜索Embedding最近邻
- MySQL - CRUD operations
- 欧拉公式的证明
- [Unity entry plan] 2D Game Kit: A preliminary understanding of the composition of 2D games
- 周鸿祎称微软抄袭,窃取360安全模式
- 架构:分布式任务调度系统(SIA-Task)简介
猜你喜欢

MySQL索引优化实战

接口测试神器Apifox究竟有多香?

灰度传感器、、、diy原理。。图

ReentrantLock工作原理

网络层解析——IP协议、地址管理、路由选择

Talking about the "horizontal, vertical and vertical" development trend of domestic ERP

Use DBeaver for mysql data backup and recovery

Safety (2)

项目场景 with ERRTYPE = cudaError CUDA failure 999 unknown error

KICAD 拉线宽度无法修改,解决方法
随机推荐
线程的不同状态
微信小程序异步回调函数恶梦和解决办法
面对职场“毕业”,PM&PMO应该如何从容的应对?如何跳槽能够大幅度升职加薪?
Good News | AR opens a new model for the textile industry, and ALVA Systems wins another award!
字符串常用方法
Curriculum Vitae;CV
AI target segmentation capability for fast video cutout without green screen
数仓:数仓从ETL到ELT架构的转化以及俩者的区别
NAS和私有云盘的区别?1篇文章说清楚
淘宝详情.
esp32经典蓝牙和单片机连接,,,手机蓝牙作为主机
2022年NPDP考完多久出成绩?怎么查询?
29. 删除链表中重复的节点
Pinduoduo leverages the consumer expo to promote the upgrading of domestic agricultural products brands and keep pace with international high-quality agricultural products
analog IC layout-Parasitic effects
局部敏感哈希:如何在常数时间内搜索Embedding最近邻
Ringtone 1161. Maximum In-Layer Elements and
【每日一道LeetCode】——9. 回文数
The state status is displayed incorrectly after the openGauss switch
接口测试神器Apifox究竟有多香?