此题是一个母函数的问题,母函数到现在我都没弄懂,幸亏看了很多网上大神们的解答,小女子才有点明白~~
#include <stdio.h>
#include <string.h>
int main(){
int n;
int dp[130][130];
int i,j;
memset(dp, 0, sizeof(dp));
dp[1][1] = 1;
for(i = 1; i <= 130; i++) {
dp[i][1] = 1;
dp[1][i] = 1;
}
for(i = 2; i <= 120; i++) {
for(j = 2; j <= 120 ; j++){
if(j > i){
dp[i][j] = dp[i][i];
}
else if(j == i){
dp[i][j] = dp[i][j-1] + 1;
}
else{
dp[i][j] = dp[i][j-1] + dp[i-j][j];
}
}
}
while(scanf("%d",&n) != EOF){
printf("%d\n",dp[n][n]);
}
return 0;
}