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 ...
随机推荐
- js自动切换图片
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- javaweb学习总结(三十八)——事务
一.事务的概念 事务指逻辑上的一组操作,组成这组操作的各个单元,要不全部成功,要不全部不成功. 例如:A——B转帐,对应于如下两条sql语句 update from account set mone ...
- 【工匠大道】markdown使用技巧
本文地址 提纲: 1. 概述 2. 常见技巧 3. 参考文档 1. 概述 常见的markdown的技巧,这里不再谈了,主要是自己感觉比较少见但有用的技巧. 2. 常见技巧 1)[空格]生成空格的效 ...
- An entity object cannot be referenced by multiple instances of IEntityChangeTracker 的解决方案
使用EF对建立了关系的表新增记录时出现: An entity object cannot be referenced by multiple instances of IEntityChangeTra ...
- 全文检索学习历程目录结构(Lucene、ElasticSearch)
1.目录 (1) Apache Lucene(全文检索引擎)—创建索引:http://www.cnblogs.com/hanyinglong/p/5387816.html (2) Apache Luc ...
- 足球宝贝来了,任你旋转(CSS3)
点击这里体验效果:http://keleyi.com/a/bjad/tfxpf3p5.htm 请使用支持CSS3的浏览器查看.请把光标放到图片上,然后再移到图片外,注意效果. 原图 大图 以下是源代码 ...
- 在SharePoint中创建可自定义属性的文件夹
概况 阅读时间:约5分钟 适用版本:SharePoint Server 2010及以上 面向用户:普通用户.管理员.开发人员 难度指数:★★★☆☆ SharePoint中的文件夹分为2种,一种是文档库 ...
- 关于SharePoint 2013的工作流(一)
从去年开始,一直和SharePoint 2013工作流打交道.自己瞎摸索,以实现功能为目的.直到如今也不知道走的路是否正确. 一开始用WF4发现整个都不一样了,用的xaml无法写后端代码.Google ...
- ASP.NET 4.0尚未在 Web 服务器上注册 解决方法
使用VS2010创建web应用程序时出现如下提示ASP.NET 4.0尚未在 Web 服务器上注册.为了使网站正确运行,可能需要手动将 Web 服务器配置为使用 ASP.NET 4.0,按 F1 可了 ...
- Android 手机卫士--设置界面&功能列表界面跳转逻辑处理
在<Android 手机卫士--md5加密过程>中已经实现了加密类,这里接着实现手机防盗功能 本文地址:http://www.cnblogs.com/wuyudong/p/5941959. ...