hdu 1028
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 int main() 5 { 6 int n,m,i,j,k; 7 int f[2][130]; 8 int now,pre; 9 while(~scanf("%d",&n)) 10 { 11 memset(f,0,sizeof(f)); 12 for(i = 0;i <= n;i ++) 13 { 14 f[1][i] = 1; // X^0 + X^1+ X^2+ .... 15 } 16 for(i = 2;i <= n;i ++) 17 { 18 now = i % 2; 19 pre =(i - 1) % 2; 20 for(j = 0;j <= n;j ++) 21 { 22 f[now][j] = 0; // 清空 23 } 24 for(j = 0;j <= n;j ++) 25 { 26 for(k = 0;k + j <= n;k += i) // 依次枚举 27 { 28 f[now][k + j] += f[pre][j]; 29 } 30 } 31 } 32 printf("%d ",f[n % 2][n]); 33 34 } 35 return 0; 36 }