当前位置:网站首页>剑指 Offer 14- II. 剪绳子 II
剑指 Offer 14- II. 剪绳子 II
2022-06-29 23:06:00 【anieoo】
solution:
贪心
const int mod = 1000000007;
class Solution {
public:
int cuttingRope(int n) {
if(n <= 3) return n - 1;
long res = 1;
while(n > 4){
res *= 3;
res = res % mod;
n -= 3;
}
return (int)(res * n % mod);
}
};边栏推荐
- Golang code specification sorting
- Leetcode(680)——验证回文字符串 Ⅱ
- Evaluation of powerful and excellent document management software: image management, book management and document management
- Discussion on distributed unique ID generation scheme
- M1笔记本居家办公的痛点及解决方案 | 社区征文
- Software testing interface testing JMeter 5.5 installation tutorial
- Label Troubleshooting: unable to open the marked image
- Solution to version conflict of flutter plug-in
- sql刷题595. 大的国家
- Uniapp copy contents to clipboard
猜你喜欢

按头安利!好看又实用的电机 SolidWorks模型素材看这里

NRM explanation

Wireshark data analysis and forensics information pacapng

Leetcode(76)——最小覆盖子串

Remember the process of checking online MySQL deadlock. You should not only know curd, but also know the principle of locking

Wechat applet: big red festive UI guessing lantern riddles is also called guessing character riddles

二叉搜索树 230. 二叉搜索树中第K小的元素 1038. 从二叉搜索树到更大和树
![The server quickly sets up the alist integrated network disk website [pagoda panel one click deployment of alist]](/img/96/3e634c173c96082881286ba402a067.png)
The server quickly sets up the alist integrated network disk website [pagoda panel one click deployment of alist]

剑指 Offer 38. 字符串的排列

Discussion on distributed unique ID generation scheme
随机推荐
動態代理的實現原理
什么是IGMP?IGMP与ICMP有啥区别?
Open source the Ernie tiny lightweight technology of "Wenxin big model", which is accurate and fast, with full effect
Leetcode 1385. 两个数组间的距离值
声网自研传输层协议 AUT 的落地实践丨Dev for Dev 专栏
Welcome the "top ten" of the Municipal Association for science and technology • pay tribute to Lu Yi, a scientific and technological worker: an explorer guarding the transmission security of the power
Label Troubleshooting: unable to open the marked image
Some of my favorite websites
基金的信息披露
关于二叉树
股票开户安全吗?上海股票开户。
论文阅读《Large-Scale Direct SLAM with Stereo Cameras》
Remember the process of checking online MySQL deadlock. You should not only know curd, but also know the principle of locking
redis客户端
Mysql database: storage engine
Solr基础操作1
FPGA开发(2)——IIC通信
Why is JSX syntax so popular?
matplotlib matplotlib中plt.hist()参数解释
自己收藏的一些网址