Dollars
uva147:
题意:给你几种钱币,在给你一个钱的数目,问有多少种用这些钱来组成这个数目。
题解:完全背包,不过此时要把钱的数目*100,因为是小数,背包的容量都是整数,然后dp,求出每个容量的数目即可
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<iomanip>
using namespace std;
int we[];
long long dp[];
int main(){
we[]=;we[]=;we[]=;we[]=;we[]=;
we[]=;we[]=;we[]=;we[]=;we[]=;we[]=;
float ss;
memset(dp,,sizeof(dp));
dp[]=;
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(j>=we[i])
dp[j]+=dp[j-we[i]];
}
}
cout<<fixed<<showpoint<<setprecision();
while(cin>>ss&&ss){
cout<<setw()<<ss<<setw()<<dp[(int)(*ss+0.5)]<<endl;//注意这里加0.5.是为了减少误差
} }
Dollars的更多相关文章
- uva 147 Dollars
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- CF# Educational Codeforces Round 3 D. Gadgets for dollars and pounds
D. Gadgets for dollars and pounds time limit per test 2 seconds memory limit per test 256 megabytes ...
- Codeforces Educational Codeforces Round 3 D. Gadgets for dollars and pounds 二分,贪心
D. Gadgets for dollars and pounds 题目连接: http://www.codeforces.com/contest/609/problem/C Description ...
- uva 147 Dollars(完全背包)
题目连接:147 - Dollars 题目大意:有11种硬币, 现在输入一个金额, 输出有多少种组成方案. 解题思路:uva 674 的升级版,思路完全一样, 只要处理一下数值就可以了. #inclu ...
- Not a million dollars ——a certain kind of ingenuity, discipline, and proactivity that most people seem to lack
原文:http://ryanwaggoner.com/2010/12/you-dont-really-want-a-million-dollars/a certain kind of ingenuit ...
- Gadgets for dollars and pounds CodeForces - 609D
Nura wants to buy k gadgets. She has only sburles for that. She can buy each gadget for dollars or f ...
- Educational Codeforces Round 3 D. Gadgets for dollars and pounds 二分+前缀
D. Gadgets for dollars and pounds time limit per test 2 seconds memory limit per test 256 megabytes ...
- codeforces 609D D. Gadgets for dollars and pounds(二分+贪心)
题目链接: D. Gadgets for dollars and pounds time limit per test 2 seconds memory limit per test 256 mega ...
- BNUOJ 17286 Dollars
Dollars Time Limit: 3000ms Memory Limit: 131072KB This problem will be judged on UVA. Original ID: 1 ...
- uva147 Dollars ——完全背包
link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
随机推荐
- hive 配置文件以及join中null值的处理
一.Hive的參数设置 1. 三种设定方式:配置文件 · 用户自己定义配置文件:$HIVE_CONF_DIR/hive-site.xml · 默认配置文件:$HIVE_CONF_DIR/hi ...
- 为Android GridView 设置行背景
经常有这样的需求,你的功能图标要像一个个物品,摆放在书架上,像这样: 我的思路比较简单,重载GridView,在他绘制子视图前,先把背景绘制完成 1 2 3 4 5 6 7 8 9 10 11 12 ...
- VB中右键换行
/r/n 能在邮件中进行换行, 在VB中使用 ASCII码的 chr(10).chr(13) 就能使VB发送邮件实现换行
- Css3渐变实例Demo(一)
1.指定渐变背景的大小 .div { background: url(../img/1.jpg); /*background-size:contain;*/ width: 500px; height: ...
- TextView使用Spannable设置复合文本
http://blog.csdn.net/linghu_java/article/details/32053167 Spannable 对文字的编辑减少TextView的拼接并且达到改变一串字符中的部 ...
- .Net framework.
Figure 1 - .Net Framework The Common Language Runtime (CLR) is the mechanism through which .NET code ...
- awk中split函数的用法
time='12:34:56' echo $time | awk '{split($0,a,":" ); print a[1]}' 12 echo $time | awk '{sp ...
- 关于UNION和UNION ALL的区别
今天在运行程序的时候发现个问题,就是计算和的时候两条数据一样的话自动去除重复的,可是我这个程序需要重复的数据也算进来呀,然后就找原因,最后在sql语句中找到了是union和union all的问题,简 ...
- ios-pch文件的手动添加
Xcode6添加pch文件 前言:Xcode6中不在为开发者自动创建pch文件,在pch文件中我们可以添加一些琐碎的宏定义,在项目中任何地方都可以引用,加快了编译的速度 Xcode6之后的版本都是需要 ...
- 苹果App store 2015最新审核标准公布(2015.3)
苹果近日更新了AppStore审核指南的相关章节,对此前版本进行了修改和完善.除了增加应用截图.预览等限制外,使用ApplePay进行定期付款的应用程序必须展示每个阶段所需款额,费用归属以及如何取消. ...