当前位置:网站首页>剑指 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);
}
};边栏推荐
- Procurement intelligence is about to break out, and the "3+2" system of Alipay helps enterprises build core competitive advantages
- 疫情下我离职一年,收入增长了10倍
- pytest初始化和清理环境
- Mysql database: storage engine
- 111. simple chat room 14: chat room client
- Open source the Ernie tiny lightweight technology of "Wenxin big model", which is accurate and fast, with full effect
- Evaluation of powerful and excellent document management software: image management, book management and document management
- 优雅的改造短信业务模块,策略模式走起!
- Hematemesis finishing: a rare map of architects!
- 关于 Apache 的 25 个初中级面试题
猜你喜欢

Leetcode 1385. Distance value between two arrays

High performance and high availability computing architecture of "Weibo comments"

新钛云服荣膺“2022爱分析 · IT运维厂商全景报告”云管理平台CMP 代表厂商!...
![PROJECT #1 - BUFFER POOL [CMU 15-445645]笔记](/img/33/304e3e78f62b156d0863a41d243679.png)
PROJECT #1 - BUFFER POOL [CMU 15-445645]笔记

二叉树的序列化 力扣 297. 二叉树的序列化与反序列化 652. 寻找重复的子树

Leetcode(680)——验证回文字符串 Ⅱ

Intranet penetration (NC)

收藏!这些提高程序员生产力的工具你用过吗?

80-Redis详解

Redis client
随机推荐
Evaluation of powerful and excellent document management software: image management, book management and document management
开源了 | 文心大模型ERNIE-Tiny轻量化技术,又准又快,效果全开
Metaq cluster installation test
3D stereo photo album, Valentine's day, couple birthday gift code applicable
The server quickly sets up the alist integrated network disk website [pagoda panel one click deployment of alist]
分布式消息中间件设计
Mysql database: the difference between drop, truncate and delete
收藏!这些提高程序员生产力的工具你用过吗?
架构实战营模块 5 作业
constexpr 函数
Open source the Ernie tiny lightweight technology of "Wenxin big model", which is accurate and fast, with full effect
label問題排查:打不開標注好的圖像
Weekly Postgres world news 2022w25
Leetcode(680)——验证回文字符串 Ⅱ
error: C2665: “QMessageBox::critical”: 4 个重载中没有一个可以转换所有参数类型
Solr基础操作4
C language tutorial – -6 loop statement
Dépannage de l'étiquette: impossible d'ouvrir l'image marquée
Qdomdocument and qdomnode are used in QT to read XML
[从零开始学习FPGA编程-51]:高阶篇 - 基于IP核的FPGA开发- 什么是FPGA IP核(软核、固核、硬核)与学习方法