Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int MaxP(int len){
- if(len==1)
- return 1;
- int res=len;
- for(int i=1;i<len;i++)
- res=max(res,i*MaxP(len-i));
- return res;
- }
- int MaxProduct(int length){
- int res=0;
- for(int i=1;i<length;i++){
- res=max(res,i*MaxP(length-i));
- }
- return res;
- }
- int main(){
- int n= 10;
- cout<<MaxProduct(n);
- return 0;
- }
Add Comment
Please, Sign In to add comment