UVA - 11137 Ingenuous Cubrency[背包DP]
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(= 213
),
i.e., coins with the denominations of 1, 8, 27, : : :, up to 9261 cubes,
are available in Cubeland.
Your task is to count the number of ways to pay a given amount
using cubic coins of Cubeland. For example, there are 3 ways to pay
21 cubes: twenty one 1 cube coins, or one 8 cube coin and thirteen 1
cube coins, or two 8 cube coin and ve 1 cube coins.
Input
Input consists of lines each containing an integer amount to be paid. You may assume that all the
amounts are positive and less than 10000.
Output
For each of the given amounts to be paid output one line containing a single integer representing the
number of ways to pay the given amount using the coins available in Cubeland.
Sample Input
10
21
77
9999
Sample Output
2
3
22
440022018293
用立方数之和凑出n有多少种方案
完全背包
体积是i*i*i,价值是1
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+;
typedef long long ll;
int n;
ll f[N];
int main(){
while(scanf("%d",&n)!=EOF){
memset(f,,sizeof(f));
f[]=;
for(int i=;i<=;i++)
for(int j=;j<=n;j++){
if(j-i*i*i>=) f[j]+=f[j-i*i*i];
//printf("%d %d %lld\n",i,j,f[i][j]);
}
printf("%lld\n",f[n]);
}
}
UVA - 11137 Ingenuous Cubrency[背包DP]的更多相关文章
- UVA 11137 Ingenuous Cubrency(dp)
Ingenuous Cubrency 又是dp问题,我又想了2 30分钟,一点思路也没有,最后又是看的题解,哎,为什么我做dp的题这么烂啊! [题目链接]Ingenuous Cubrency [题目类 ...
- uva 11137 Ingenuous Cubrency
// uva 11137 Ingenuous Cubrency // // 题目大意: // // 输入正整数n,将n写成若干个数的立方之和,有多少种 // // 解题思路: // // 注意到n只有 ...
- uva 11137 Ingenuous Cubrency(完全背包)
题目连接:11137 - Ingenuous Cubrency 题目大意:由21种规模的立方体(r 1~21),现在给出一个体积, 要求计算可以用多少种方式组成. 解题思路:完全背包, 和uva674 ...
- 【Java】【滚动数组】【动态规划】UVA - 11137 - Ingenuous Cubrency
滚动数组优化自己画一下就明白了. http://blog.csdn.net/u014800748/article/details/45849217 解题思路:本题利用递推关系解决.建立一个多段图,定义 ...
- 【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 * ...
- UVA 10306 e-Coins(全然背包: 二维限制条件)
UVA 10306 e-Coins(全然背包: 二维限制条件) option=com_onlinejudge&Itemid=8&page=show_problem&proble ...
- 背包dp整理
01背包 动态规划是一种高效的算法.在数学和计算机科学中,是一种将复杂问题的分成多个简单的小问题思想 ---- 分而治之.因此我们使用动态规划的时候,原问题必须是重叠的子问题.运用动态规划设计的算法比 ...
- hdu 5534 Partial Tree 背包DP
Partial Tree Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...
- HDU 5501 The Highest Mark 背包dp
The Highest Mark Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?p ...
随机推荐
- 【C#进阶系列】22 CLR寄宿和AppDomain
关于寄宿和AppDomain 微软开发CLR时,将它实现成包含在一个DLL中的COM服务器. 任何Windows应用程序都能寄宿(容纳)CLR.(简单来讲,就是CLR在一个DLL中,通过引用这个DLL ...
- 为什么document.firstChild找到的不是html节点
DOM是针对HTML4.01开发的,我们现在是XHTML1.0. 所以要想使用核心DOM中的属性和方法,必须去掉DTD类型定义. <!DOCTYPE html PUBLIC "-//W ...
- PHP 检测机器人,屏蔽内页
PHP 检测机器人,屏蔽内页 <?php // SpiderHelper::rewrite301(); // SpiderHelper::showRobotTxt(); class Spider ...
- 【Java每日一题】20161215
package Dec2016; public class Ques1215 { static final int num1 = 2; static final int num2 = 3; stati ...
- sqlserver附加 mdf、ldf的方法(手记)
exec sp_attach_db 'bookstore','E:\homework\bookstore_Data.MDF','E:\homework\bookstore_Log.LDF' EXEC ...
- VBA初试——合并
今天遇到一个任务,要把excel中的相同行合并:没有找到直接的办法(vlookup大概能做),试了试VBA挺好用 数据结构 第一.二列是描述字段,第二列元素唯一:第三到第八列是标志位 任务 合并描述字 ...
- PHP 命名空间(namespace)
PHP 命名空间(namespace) PHP 命名空间(namespace)是在PHP 5.3中加入的,如果你学过C#和Java,那命名空间就不算什么新事物. 不过在PHP当中还是有着相当重要的意义 ...
- WCF入门教程1——WCF简要介绍
什么是WCF Windows Communication Foundation(WCF)是由微软开发的一系列支持数据通信的应用程序框架,可以翻译为Windows 通讯开发平台. 整合了原有的windo ...
- OData V4 系列 服务创建
OData 学习目录 创建应用程序 添加引用 install-package entityframework . Install-Package Microsoft.AspNet.Odata . In ...
- JavaScript强化教程 —— Cocos2d-JS的屏幕适配方案
1. 设置屏幕适配策略(Resolution Policy) 如果你还没有用过Resolution Policy,只需要在游戏载入过程完成之后(cc.game.onStart函数回调中),调用下面的代 ...