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 ...
随机推荐
- ASP.NET MVC 了解FileResult的本质
FileResult是一个基于文件的ActionResult,利用FileResult我们可以很容易地将从某个物理文件的内容响应给客户端.ASP.NET MVC定义了三个具体的FileResult,分 ...
- 背水一战 Windows 10 (36) - 控件(弹出类): ToolTip, Popup, PopupMenu
[源码下载] 背水一战 Windows 10 (36) - 控件(弹出类): ToolTip, Popup, PopupMenu 作者:webabcd 介绍背水一战 Windows 10 之 控件(弹 ...
- Python获取中国证券报最新资讯
# -*- coding: utf-8 -*- import urllib from bs4 import BeautifulSoup from time import time from time ...
- hibernate(3) —— 关系映射
hibernate中关系映射指的是实体类与实体类间的关系.和数据库中表与表之间的关系类似,有一对一,多对一,一对多,多对多四种映射关系. 一:一对一映射 两个对象之间是一对一的关系,如人和身份证之间是 ...
- 12种不适宜使用的javascript语法
1. == (o゜▽゜)o☆[BINGO!] Javascript有两组相等运算符,一组是==和!=,另一组是===和!==.前者只比较值的相等,后者除了值以外,还比较类型是否相同. 请尽量不要使用前 ...
- javascript移动设备Web开发中对touch事件的封装实例
在触屏设备上,一些比较基础的手势都需要通过对 touch 事件进行二次封装才能实现.zepto 是移动端上使用率比较高的一个类库,但是其 touch 模块模拟出来的一些事件存在一些兼容性问题,如 ta ...
- iOS 应用评分
为了提高应用的用户体验,经常需要邀请用户对应用进行评分 应用评分无非就是跳转到AppStore展示自己的应用,然后由用户自己撰写评论 如何跳转到AppStore,并且展示自己的应用 方法1 NSStr ...
- K近邻模型(k-NN)
原理 K最近邻(k-Nearest Neighbor,KNN)分类算法,是一个理论上比较成熟的方法,也是最简单的机器学习算法之一.该方法的思路是:如果一个样本在特征空间中的k个最相似(即特征空间中最邻 ...
- 在eclipse中把Tomcat 8删掉不能重建问题,启动Tomcat重置本地配置问题
转载:http://blog.csdn.net/caiwenfeng_for_23/article/details/45480039 PS: 今天手贱,把Eclipse里的tomcat删掉了,然后发现 ...
- iOS 杂笔-25(不要用copy修饰NSMutableString)
iOS 杂笔-25(不要用copy修饰NSMutableString) 首先对题目进行简单的解释,我所说的不要用copy修饰NSMutableString不是说完全不可以用.但是要清楚一点,既然使用N ...