题意:你现在有面额为A的纸币,现在需要面额为B的钱(可以是一张也可以是好多张拼成一张),有一台自动售货机,里面有任意价格的商品,售货机兑换出的零钱是随机的(比如找你0.03可能给你0.01+0.01+0.01也可能是0.01+0.02),那么问至少要花多少钱你肯定能兑换到所需要的面额。A, B ∈ {0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20, 50, 100} and A > B

思路:题意读错了...这里的意思不是你只能买一个东西,而是你买了之后可以用找零的钱继续买,那么如果0.01可以解决那么就是0.01,其他的只要用零钱继续0.01就可以了。

代码:

#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<string>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<algorithm>
typedef long long ll;
using namespace std;
const int maxn = + ;
const int MOD = 1e9 + ;
const int INF = 0x3f3f3f3f;
int main(){
int t, ca = ;
scanf("%d", &t);
while(t--){
double a, b;
scanf("%lf%lf", &a, &b);
printf("Case #%d: ", ca++);
if(b == 0.01){ //0.03
if(a == 0.02){
printf("0.01\n");
}
else if(a == 0.05){
printf("0.02\n");
}
else{
printf("0.02\n");
}
}
else if(b == 0.02){ //0.04 0.09
if(a == 0.05){
printf("0.01\n");
}
else{
printf("0.01\n");
}
}
else if(b == 0.05){ //0.09
printf("0.01\n");
}
else if(b == 0.1){ //0.39
if(a == 0.2) printf("0.01\n");
else if(a == 0.5) printf("0.02\n");
else printf("0.02\n");
}
else if(b == 0.2){ //0.49 0.99
if(a == 0.5) printf("0.01\n");
else printf("0.01\n");
}
else if(b == 0.5){ //0.99
printf("0.01\n");
}
else if(b == ){ //3.99
if(a == ) printf("0.01\n");
else if(a == ) printf("0.02\n");
else printf("0.02\n");
}
else if(b == ){ //4.99 9.99
if(a == ) printf("0.01\n");
else printf("0.01\n");
}
else if(b == ){ //9.99
printf("0.01\n");
}
else if(b == ){ //39.99
if(a == ) printf("0.01\n");
else printf("0.02\n");
}
else if(b == ){ //49.99 99.99
if(a == ) printf("0.01\n");
else printf("0.01\n");
}
else{ //99.99
printf("0.01\n");
}
}
return ;
}

UVALive 7503 Change(乱搞)题解的更多相关文章

  1. UVaLive 7503 Change (坑题。。。。。。)

    题意:给定两个人民币,问你花最少钱保证能够凑出另一个价格. 析:这个题最大的坑就是在,并一定是一次就凑出来,可以多次,然后就可以想了,如果要凑的数和1有关,特判,如果是2倍数,0.01就够了,否则就是 ...

  2. “盛大游戏杯”第15届上海大学程序设计联赛夏季赛暨上海高校金马五校赛题解&&源码【A,水,B,水,C,水,D,快速幂,E,优先队列,F,暴力,G,贪心+排序,H,STL乱搞,I,尼姆博弈,J,差分dp,K,二分+排序,L,矩阵快速幂,M,线段树区间更新+Lazy思想,N,超级快速幂+扩展欧里几德,O,BFS】

    黑白图像直方图 发布时间: 2017年7月9日 18:30   最后更新: 2017年7月10日 21:08   时间限制: 1000ms   内存限制: 128M 描述 在一个矩形的灰度图像上,每个 ...

  3. 2016 10 28考试 dp 乱搞 树状数组

    2016 10 28 考试 时间 7:50 AM to 11:15 AM 下载链接: 试题 考试包 这次考试对自己的表现非常不满意!! T1看出来是dp题目,但是在考试过程中并没有推出转移方程,考虑了 ...

  4. 【BZOJ-3578】GTY的人类基因组计划2 set + map + Hash 乱搞

    3578: GTY的人类基因组计划2 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 367  Solved: 159[Submit][Status][ ...

  5. UESTC 1272 Final Pan's prime numbers(乱搞)

    题目链接 Description Final Pan likes prime numbers very much. One day, he want to find the super prime n ...

  6. [bzoj1067][SCOI2007]降雨量——线段树+乱搞

    题目大意 传送门 题解 我国古代有一句俗话. 骗分出奇迹,乱搞最神奇! 这句话在这道题上得到了鲜明的体现. 我的方法就是魔改版线段树,乱搞搞一下,首先借鉴了黄学长的建树方法,直接用一个节点维护年份的区 ...

  7. 帮助Bsny(乱搞做法)

    帮助Bsny 题目描述 Bsny的书架乱成一团了,帮他一下吧! 他的书架上一共有n本书,我们定义混乱值是连续相同高度书本的段数.例如,如果书的高度是30,30,31,31,32,那么混乱值为3:30, ...

  8. hash进阶:使用字符串hash乱搞的姿势

    前言 此文主要介绍hash的各种乱搞方法,hash入门请参照我之前这篇文章 不好意思hash真的可以为所欲为 在开头先放一下题表(其实就是我题解中的hash题目qwq) 查询子串hash值 必备的入门 ...

  9. 【uoj#209】[UER #6]票数统计 组合数+乱搞

    题目描述 一个长度为 $n$ 的序列,每个位置为 $0$ 或 $1$ 两种.现在给出 $m$ 个限制条件,第 $i$ 个限制条件给出 $x_i$ .$y_i$ ,要求至少满足以下两个条件之一: 序列的 ...

随机推荐

  1. 15. 3Sum(字典)

    Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find ...

  2. JVM调优总结 -Xms

    转载自:http://unixboy.iteye.com/blog/174173/ 设置eclipse : -Xms256M -Xmx512M -XX:PermSize=256m -XX:MaxPer ...

  3. redis的数据类型命令

    存储sortedset: 存储:zadd key score menber1 score menber2 ... 升序排列:zrange key start end [withscores] 降序排列 ...

  4. linux常用命令:rmdir 命令

    今天学习一下linux中命令: rmdir命令.rmdir是常用的命令,该命令的功能是删除空目录,一个目录被删除之前必须是空的.(注意,rm - r dir命令可代替rmdir,但是有很大危险性.)删 ...

  5. Flask内置URL变量转换器

    Flask内置URL变量转换器: 转换器通过特定的规则执行,”<转换器: 变量名>”.<int: year>把year的值转换为证书,因此我们可以在视图函数中直接对year变量 ...

  6. 原生JavaScript插件编写指南(转载)

    原生js开发指南 https://www.jianshu.com/p/e65c246beac1 在jQuery大量使用的环境下,目前网上的众多jQuery插件也能基本满足要求,但是在项目具体需求下,有 ...

  7. Selenium自动化测试,接口自动化测试开发,性能测试从入门到精通

    Selenium自动化测试,接口自动化测试开发,性能测试从入门到精通Selenium接口性能自动化测试基础部分:分层自动化思想Slenium介绍Selenium1.0/2.0/3.0Slenium R ...

  8. 100.容器List-ArrayList

    package collection; import java.util.ArrayList; import java.util.Collection; import java.util.Date; ...

  9. GUI常用对象的属性

    %常用对象的属性 %.figure %hf=figure; %get(hf); %改变颜色 set Color %set(hf,'Color','w'); %去掉默认的菜单 Menubar %set( ...

  10. C++形参中const char * 与 char * 的区别

    在函数调用时,我们经常看见一个函数的接受参数为(const char *); 例如strlen()函数,它的定义为: size_t strlen( const char *str); 那么将形参设置为 ...