技术栈

Java | Leetcode Java题解之第343题整数拆分

m0_571957582024-08-18 22:10

题目:

题解:

java 复制代码
class Solution {
    public int integerBreak(int n) {
        if (n <= 3) {
            return n - 1;
        }
        int quotient = n / 3;
        int remainder = n % 3;
        if (remainder == 0) {
            return (int) Math.pow(3, quotient);
        } else if (remainder == 1) {
            return (int) Math.pow(3, quotient - 1) * 4;
        } else {
            return (int) Math.pow(3, quotient) * 2;
        }
    }
}
上一篇:已解决:java.net.BindException: 地址已在使用
下一篇:Java TCP练习1
相关推荐
t***4423
3 小时前
【Springboot3+vue3】从零到一搭建Springboot3+vue3前后端分离项目之后端环境搭建
java
daidaidaiyu
3 小时前
SpringCloud 微服务实现一则 (Eureka + Hystrix)
java·spring
小哥不太逍遥
3 小时前
Technical Report 2024
java·服务器·前端
edisao
4 小时前
序幕-内部审计备忘录
java·jvm·算法
shehuiyuelaiyuehao
4 小时前
22Java对象的比较
java·python·算法
常利兵
5 小时前
吃透Java操作符高阶:位操作符+赋值操作符全解析(Java&C区别+实战技巧+面试考点)
java·c语言·面试
不用89k
5 小时前
SpringBoot学习新手项初识请求
java·spring boot·学习
码农阿豪
5 小时前
SpringBoot实现公正有趣好玩的年会抽奖系统
java·spring boot·后端
Java爱好狂.
5 小时前
RDB&AOF持久化原理解析
java·数据库·redis·后端开发·java编程·java程序员·java八股文
hashiqimiya
6 小时前
gradle.properties使用系统代理
java
热门推荐
01GitHub 镜像站点02Claude Code + GLM4.7 避坑指南:解决 Unable to connect to Anthropic services03openClaw安装飞书插件|核心踩坑:spawn EINVAL 错误终极解决指南04HTB 赛季10 - Pterodactyl - user05openclaw 配置飞书 报错 应用未建立长连接06UV安装并设置国内源07243 行 microGPT:把“训练 + 推理”拆到骨头里08如何解决 OpenClaw “Pairing required” 报错:两种官方解决方案详解09AI 规范驱动开发“三剑客”深度对比:Spec-Kit、Kiro 与 OpenSpec 实战指南10openclaw配置教程(linux+局域网ollama)