同样的思路,只是解决的问题不一样
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int func(int pre,int now){
int max_ = -1;
for (int i=1;2*i<=now;i++){
if (i>=pre){
max_ = max(max_,max(i*(now-i),func(i,now-i)));
}
}
return pre*max_;
}
int main(){
int m;
scanf("%d",&m);
printf("%d",func(1,m));
return 0;
}