当前位置:网站首页>Sword finger offer cut rope
Sword finger offer cut rope
2022-07-27 15:14:00 【A fool is a little proud】
Title Description
I'll give you a length of n The rope of , Please cut the rope into m paragraph (m、n Are integers. ,n>1 also m>1), The length of each rope is recorded as k[0],k[1],...,k[m]. Excuse me, k[0]xk[1]x...xk[m] What's the maximum possible product ? for example , When the length of the rope is 8 when , We cut it into lengths of 2、3、3 Three paragraphs of , The maximum product we get here is 18
Multiplication , Except one , The more numbers you multiply, the greater the result
from 2 Begin to think about , If you use 2 piecewise , The existence of odd numbers will leave one 2,1, At this time
It should be replaced by 3, therefore 2,3 piecewise
2*2*2<3*3, Should let 3 As much as possible
Usage %3, Remainder is 2 There is a 2, by 1 There are two 2class Solution { public: int cutRope(int target) { if(target<=3)return target-1; int res=1;//%3=0 if(target%3==1){ res=4; target-=4; }else if(target%3==2){ res=2; target-=2; } while(target){ res*=3; target-=3; } return res; } };
边栏推荐
- ADB command (install APK package format: ADB install APK address package name on the computer)
- TCC
- 被动收入:回归原始且安全的两种赚取方法
- STM32 CAN 通信 滤波设置问题
- 华云数据打造完善的信创人才培养体系 助力信创产业高质量发展
- Jmeter录制接口自动化
- Design scheme of digital oscilloscope based on stm32
- 网络设备硬核技术内幕 路由器篇 11 CISCO ASR9900拆解 (五)
- 积分运算电路的设计方法详细介绍
- [Yunxiang book club issue 13] multimedia processing tool ffmpeg tool set
猜你喜欢

CAN总线的EMC设计方案

工具 - markdown编辑器常用方法

Unity 鼠标控制第一人称摄像机视角

Lecture 4: Longest ascending substring

JMeter recording interface automation

Kotlin的基础用法

Finally, someone finished all the dynamic planning, linked list, binary tree and string required for the interview

LeetCode 781. 森林中的兔子 哈希表/数学问题 medium

积分运算电路的设计方法详细介绍
![[ManageEngine] what is Siem](/img/a6/0fbe60df6bef337a91a10fe046aa8a.jpg)
[ManageEngine] what is Siem
随机推荐
网络设备硬核技术内幕 路由器篇 14 从鹿由器到路由器 (中)
The database uses PSQL and JDBC to connect remotely and disconnect automatically from time to time
Kubernetes CNI 分类/运行机制
Unity性能优化------渲染优化(GPU)之Occlusion culling(遮挡剔除)
Kotlin的基础用法
LeetCode 781. 森林中的兔子 哈希表/数学问题 medium
Jmeter录制接口自动化
HDU3117 Fibonacci Numbers【数学】
同花顺开户在手机开户安全吗?
代码覆盖率统计神器-jacoco工具实战
The reverse order pairs in the "sword finger offer" array
Understand the evolution of redis architecture in one article
Graphical SQL is too vivid
The mobile terminal uses the list component of vantui. When multiple tab items are switched back and forth, the list is loaded many times, resulting in the failure of normal display of data
USB接口电磁兼容(EMC)解决方案
【WORK】关于技术架构
CAN总线的EMC设计方案
网络设备硬核技术内幕 路由器篇 3 贾宝玉梦游太虚幻境 (中)
【云享读书会第13期】多媒体处理工具 FFmpeg 工具集
基于stm32的数字示波器设计方案