标签:style blog http color os io ar for art
题意:用13、23……k3这些数加起来组成n,输出总方案数
d(i, j)表示前i个数构成j的方案数则有
d(i, j) = d(i-1, j) + d(i, j - i3)
可以像01背包那样用滚动数组来实现
1 //#define LOCAL 2 #include <iostream> 3 #include <cstdio> 4 #include <cstring> 5 using namespace std; 6 7 const int maxn = 10; 8 long long dp[maxn + 10]; 9 10 int main(void) 11 { 12 #ifdef LOCAL 13 freopen("11137in.txt", "r", stdin); 14 #endif 15 16 dp[0] = 1; 17 for(int i = 1; i <= 21; ++i) 18 { 19 int v = i * i * i; 20 for(int j = v; j <= maxn; ++j) 21 dp[j] += dp[j - v]; 22 } 23 int n; 24 while(scanf("%d", &n) == 1) 25 printf("%lld\n", dp[n]); 26 return 0; 27 }
UVa 11137 (完全背包方案数) Ingenuous Cubrency
标签:style blog http color os io ar for art
原文地址:http://www.cnblogs.com/AOQNRMGYXLMV/p/3948262.html