UVa11137 Ingenuous Cubrency
2012-11-19 23:47
393 查看
原题传送:http://uva.onlinejudge.org/external/111/11137.html
递推,动态规划。
d[i][j]表示使用不超过i的 i 的整数的立方,累加和为 j 的方案数。
则有状态转移方程:
d[i][j] = d[i - 1][j] + d[i][j - i3]。
初始条件d[0][0] = 1;
View Code
递推,动态规划。
d[i][j]表示使用不超过i的 i 的整数的立方,累加和为 j 的方案数。
则有状态转移方程:
d[i][j] = d[i - 1][j] + d[i][j - i3]。
初始条件d[0][0] = 1;
View Code
#include <stdio.h> #include <string.h> typedef long long LL; const int maxi = 21; const int maxn = 10000; LL d[maxi + 2][maxn + 5]; void init() { memset(d, 0, sizeof d); d[0][0] = 1; for(int i = 1; i <= maxi; i ++) { for(int j = 0; j <= maxn; j ++) { if(j - i * i * i >= 0) d[i][j] = d[i - 1][j] + d[i][j - i * i * i]; else d[i][j] = d[i - 1][j]; } } } int main() { init(); int n; while(scanf("%d", &n) == 1) { printf("%lld\n", d[maxi] ); } return 0; }
相关文章推荐
- uva 11137 - Ingenuous Cubrency
- UVa:11137 Ingenuous Cubrency
- uva 11137 Ingenuous Cubrency(完全背包)
- UVa 11137 - Ingenuous Cubrency (递推 DP 多重背包 )
- UVa 11137 - Ingenuous Cubrency 背包
- UVa-11137 Ingenuous Cubrency
- uva 11137 Ingenuous Cubrency
- UVA 11137 Ingenuous Cubrency(完全背包)
- UVa 11137 - Ingenuous Cubrency 背包
- UVA - 11137 Ingenuous Cubrency
- UVa 11137 - Ingenuous Cubrency
- UVa 11137 - Ingenuous Cubrency
- UVA 11137 Ingenuous Cubrency 类似硬币问题的简单dp
- Ingenuous Cubrency UVA 11137
- 动态规划,递推,多段图(Ingenuous Cubrency,uva 11137)
- UVa 11137 - Ingenuous Cubrency
- uva 11137 Ingenuous Cubrency
- Matches UVA - 11375 递推+大数 Ingenuous Cubrency UVA - 11137 递推
- UVA_11137_Ingenuous Cubrency
- Matches UVA - 11375 递推+大数 Ingenuous Cubrency UVA - 11137 递推