UVa 11137 - Ingenuous Cubrency

题目:统计一个数字可以有多少种立方和的表示方式。

分析:dp,完全背包。又见整数拆分。

说明:csdn冲进前1000了,(*^__^*) 嘻嘻……。

#include <iostream>
#include <cstdlib>
#include <cstring>

using namespace std;

int cube[25];
long long F[10001];

int main()
{
	for (int i = 0 ; i <= 21 ; ++ i)
		cube[i] = i*i*i;
	for (int i = 0 ; i < 10000 ; ++ i)
		F[i] = 0LL;
	F[0] = 1LL;
	for (int i = 1 ; i <= 21 ; ++ i)
	for (int j = cube[i] ; j < 10000 ; ++ j)
		F[j] += F[j-cube[i]];

	int n;
	while (cin >> n)
		cout << F[n] << endl;

	return 0;
}
时间: 2024-10-14 11:25:11

UVa 11137 - Ingenuous Cubrency的相关文章

uva 11137 Ingenuous Cubrency (完全背包)

uva 11137 Ingenuous Cubrency People in Cubeland use cubic coins. Not only the unit of currency is called a cube but also the coins are shaped like cubes and their values are cubes. Coins with values of all cubic numbers up to 9261 (= 21 3), i.e., coi

【Java】【滚动数组】【动态规划】UVA - 11137 - Ingenuous Cubrency

滚动数组优化自己画一下就明白了. http://blog.csdn.net/u014800748/article/details/45849217 解题思路:本题利用递推关系解决.建立一个多段图,定义状态d(i,j)表示"使用不超过i的整数的立方,累加和为j"的方案数.那么根据加法原理,如果没有选择数字i的立方和就得到了j,那么方案数就是d(i-1,j):如果选择了数字i的立方和才得到了j,那么方案数是d(i,j-i^3).即: d(i,j)=d(i-1,j)+d(i,j-i^3);

UVA - 11137 Ingenuous Cubrency[背包DP]

People in Cubeland use cubic coins. Not only the unit of currency iscalled a cube but also the coins are shaped like cubes and their valuesare cubes. Coins with values of all cubic numbers up to 9261(= 213),i.e., coins with the denominations of 1, 8,

【UVA】11137-Ingenuous Cubrency

DP问题,须要打表. dp[i][j]代表利用大小不超过i的数字组成j的方法. 状态方程是 dp[i][j] = d[i - 1][j] + sum{dp[i - 1][j - k * i * i *i]}; 14327705 11137 Ingenuous Cubrency Accepted C++ 0.049 2014-10-09 10:20:48 #include<cstdio> #include<cstring> #include<algorithm> #inc

UVa 11137 (完全背包方案数) Ingenuous Cubrency

题意:用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

完全背包——方案个数 UVA11137 Ingenuous Cubrency

题目描述如下 : 代码如下: #include <stdio.h> unsigned long long int dp[10001] ; int main (){ int i,j ,k ; int v[22]; int n ; for (i = 1 ; i < 22 ; i ++) v[i] = i*i*i ; dp [0] = 0 ; for ( i = 1 ; i <=21 ; i ++ ){ for ( j = 0 ; j<10001 ; j ++ ){ if ( j&

UVA11137 Ingenuous Cubrency

题意 PDF 分析 考虑dp. 用\(d(i,j)\)表示用不超过i的立方凑成j的方案数. \(d(i,j)=d(i-1,j)+d(i,j-i^3)\) 时间复杂度\(O(IN+T)\) 代码 #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<set> #include<map> #include<queue> #i

UVA题目分类

题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes

算法入门经典大赛 Dynamic Programming

111 - History Grading LCS 103 - Stacking Boxes 最多能叠多少个box DAG最长路 10405 - Longest Common Subsequence LCS 674 - Coin Change 全然背包求方案数 10003  - Cutting Sticks 区间DP dp[l][r]代表分割l到r的最小费用 116 - Unidirectional TSP 简单递推 输出字典序最小解 从后往前推 10131 - Is Bigger Smarte