题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=1028
解题思路:
母函数模板题。
AC代码:
#include <iostream> #include <cstdio> using namespace std; int main(){ int n; while(~scanf("%d",&n)){ int c1[130],c2[130]; for(int i = 0; i <= n; i++){ c1[i] = 1; c2[i] = 0; } for(int i = 2; i <= n; i++){ for(int j = 0; j <= n; j++) for(int k = 0; k+j <= n; k += i) c2[j+k] += c1[j]; for(int j = 0; j <= n; j++){ c1[j] = c2[j]; c2[j] = 0; } } printf("%d\n",c1[n]); } return 0; }