UVa 357 - Let Me Count The Ways
题目大意:也是硬币兑换问题,与147、674用同样的方法即可解决。
#include <cstdio>
#include <cstring>
#define MAXN 30001 const int coin[] = {, , , , };
long long dp[MAXN]; int main()
{
#ifdef LOCALi
freopen("in", "r", stdin);
#endif
memset(dp, , sizeof(dp));
dp[] = ;
for (int k = ; k < ; k++)
for (int i = ; i < MAXN; i++)
if (i >= coin[k])
dp[i] += dp[i-coin[k]];
int n;
while (scanf("%d", &n) != EOF)
{
if (dp[n] == ) printf("There is only 1 way to produce %d cents change.\n", n);
else printf("There are %lld ways to produce %d cents change.\n", dp[n], n);
}
return ;
}
UVa 357 - Let Me Count The Ways的更多相关文章
- UVA 357 Let Me Count The Ways(全然背包)
UVA 357 Let Me Count The Ways(全然背包) http://uva.onlinejudge.org/index.php?option=com_onlinejudge& ...
- UVA.357 Let Me Count The Ways (DP 完全背包)
UVA.357 Let Me Count The Ways (DP 完全背包) 题意分析 与UVA.UVA.674 Coin Change是一模一样的题.需要注意的是,此题的数据量较大,dp数组需要使 ...
- uva 357 Let Me Count The Ways(01背包)
题目连接:357 - Let Me Count The Ways 题目大意:有5种硬币, 面值分别为1.5.10.25.50,现在给出金额,问可以用多少种方式组成该面值. 解题思路:和uva674是一 ...
- Uva 10007 / HDU 1131 - Count the Trees (卡特兰数)
Count the Trees Another common social inability is known as ACM (Abnormally Compulsive Meditation) ...
- UVa 1645 (递推) Count
题意: 有多少个n个节点的有根树,满足每层节点的子节点个数相同,输出该数目除以1e9+7的余数. 分析: 这种题目就属于那种,看起来很高冷,读完题更高冷.想了N久想不出来,一搜题解,卧槽,这么sb的题 ...
- Let Me Count The Ways(Kickstart Round H 2018)
题目链接:https://code.google.com/codejam/contest/3324486/dashboard#s=p2 题目: 思路: 代码实现如下: #include <set ...
- kickstart_2018_round_H_C Let Me Count The Ways
思路: 容斥. 实现: #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ; ll f[MAXN ...
- UVA题目分类
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...
- 算法入门经典大赛 Dynamic Programming
111 - History Grading LCS 103 - Stacking Boxes 最多能叠多少个box DAG最长路 10405 - Longest Common Subsequence ...
随机推荐
- CentOS Hadoop安装配置详细
总体思路,准备主从服务器,配置主服务器可以无密码SSH登录从服务器,解压安装JDK,解压安装Hadoop,配置hdfs.mapreduce等主从关系. 1.环境,3台CentOS7,64位,Hadoo ...
- listview去掉条目间的分割线
未去掉前: 去掉后: java代码可以这么写: 1 listView.setDivider(null);//去掉条目间的分割线 PS:ListView的几个常用操作 listView ...
- 格式化一个文件的大小(size),或者说是格式化一个app的大小(size)
long number = 6243161; Formatter.formatFileSize(context, number): 需要导包,import android.text.format.Fo ...
- IDL 的读写
read_ifc代码如下: Write_ifc代码分析如下: (1)将数字转换为字符串的函数. function ntoc,a return,string(a,format='(g0)') end ( ...
- Changing a remote's URL
原文: https://help.github.com/articles/changing-a-remote-s-url/ Changing a remote's URL MAC WINDOWS LI ...
- automaticallyAdjustsScrollViewInsets 标签栏不正常显示
想做的效果如下: 结果那个首页.手办模型神马的就是不显示啊... 这个标签栏是用scrollView做的,解决办法: viewController.automaticallyAdjustsScroll ...
- android Spinner 续
android Spinner 续 动态增删Spinner中的数据项 public class EX04_09 extends Activity{ private static final Stri ...
- PAT (Advanced Level) 1092. To Buy or Not to Buy (20)
简单题. #include<cstdio> #include<cstring> ; char s1[maxn],s2[maxn]; ]; ]; int main() { sca ...
- Apache下的FileUtils.listFiles方法简单使用技巧
一.引言 Apache提供的很多工具方法非常好用,推荐. 今天在使用的过程中使用到了org.apache.commons.io.FileUtils.listFiles方法,本文主要谈谈这个工具方法的用 ...
- 数据库建表的时候报 “1215 Cannot add foreign key constraint”
很大原因是因为: 引用表中的字段类型和被引用的主键的类型不统一. 比如说学生表中有一个班级ID字段引用班级表. 班级表的ID是int类型,学生表中的班级ID是Varchar类型. 肯定会提示上述121 ...