题意:给出一个N,问N的划分数
题解:显然n的划分数等于(1+x+x^2+...)*(1+x^2+x^4+...)*(1+x^3+x^6+...) 的结果中x^n次前的系数
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200;
int n;
int c1[maxn], c2[maxn];
int main(){
while (~scanf("%d", &n)){
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++){前i-1个表达式相乘的系数
for (int k = 0; k + j <= n; k += i){第i个表达式的系数
c2[k + j] += c1[j];
}
}
for (int j = 0; j <= n; j++){
c1[j] = c2[j];
c2[j] = 0;
}
}
printf("%d\n", c1[n]);
}
return 0;
}