首页 > 试题广场 >

整数成绩最大化

[编程题]整数成绩最大化
  • 热度指数:2568 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
给出一个整数n,将n分解为至少两个整数之和,使得这些整数的乘积最大化,输出能够获得的最大的乘积。
例如:
2=1+1,输出1;
10=3+3+4,输出36。

输入描述:
输入为1个整数


输出描述:
输出为1个整数
示例1

输入

10

输出

36
头像 three_0430
发表于 2024-03-03 16:13:08
#include <bits/stdc++.h> using namespace std; int main() { int n; while (cin >> n) { // 注意 while 处理多个 case int result = 1 展开全文
头像 three_0430
发表于 2024-03-03 17:01:02
#include <iostream> #include <vector> using namespace std; int integerBreak(int n) { vector<int> dp(n + 1, 0);//dp[i]表示整数i分解为至少 展开全文
头像 小蒲想变强
发表于 2021-09-01 23:06:50
核心思想:一个数不断拆成3时有最大乘积。此题纯粹考察数学思维,想得到就能解,否则可能连思路都没有。将一个正整数拆分,使其乘机最大。当数值在4及以上时,无论值的大小都可以拆解为 3和其小于3的余数。例如:7==3+2+2;15==3+3+3+3+3;11==3+3+3+2;并且 32>5 3*3 展开全文
头像 你快乐吗
发表于 2020-12-16 20:00:25
import java.util.Scanner; public class T_test { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); 展开全文