题意:给定一个整数n,问有多少种方式划分整数,如3可以划分为1+1+1,1+2,3,三种方式
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int N = 125;
int f1[N],f2[N];
int n;
int main(){
while(~scanf("%d",&n)){
memset(f1,0,sizeof f1);
memset(f2,0,sizeof f2);
for(int i = 0;i <= n;i ++)
f1[i] = 1;
for(int i = 2;i <= n;i ++){
for(int j = 0;j <= n;j ++)
for(int k = 0;k + j <= n;k += i){
f2[j + k] += f1[j];
}
for(int j = 0;j <= n;j ++){
f1[j] = f2[j];
f2[j] = 0;
}
}
cout << f1[n] << endl;
}
return 0;
}
orzorz