题目描述
Given a rope of length N meters, cut the rope into several ropes of varying lengths in a way that maximizes product of lengths of all resulting ropes. You must make at least one cut.
Example 1:
Input:
N = 2
Output: 1
Explanation: Since 1 cut is mandatory.
Maximum obtainable product is 11 = 1.
Example 2:
Input:
N = 5
Output: 6
Explanation:
Maximum obtainable product is 23 = 6.
Your Task:
You don't need to read input or print anything. Your task is to complete the function maxProduct() which takes n as input parameter and returns the maximum product.
Expected Time Complexity: O(N^{2})
Expected Auxiliary Space: O(N)
Constraints:
1 ≤ N ≤ 100
输入格式
见题面
输出格式
见题面
样例输入
N = 2
样例输出
1