标签:style blog color io os for sp div on
题意:给出n,问将n拆成若干个正整数只和,有多少种方法。
#include <cstdio> #include <cstring> #include <algorithm> #include <climits> #include <string> #include <iostream> #include <map> #include <cstdlib> #include <list> #include <set> #include <queue> #include <stack> #include <math.h> using namespace std; typedef long long LL; const LL maxn = 10000; const LL maxm = 24; LL dp[maxm + 100][maxn + 100]; void init() { memset(dp, 0, sizeof(dp)); dp[0][0] = 1; for (LL i = 1; i <= maxm; i++){ for (LL j = 0; j <= maxn; j++){ for (LL k = 0; j + k*i*i*i <= maxn; k++){ dp[i][j + k*i*i*i] += dp[i - 1][j]; } } } } int main() { LL n; init(); while (cin >> n){ cout << dp[maxm][n] << endl; } return 0; }
标签:style blog color io os for sp div on
原文地址:http://www.cnblogs.com/yigexigua/p/4018394.html