UVALive
来源:互联网 发布:最近网络上很火的舞蹈 编辑:程序博客网 时间:2024/06/02 03:01
链接:点击打开链接
题意:有一个自动贩卖机,你想用它来换零钱,你目前有的钱A,想得到B,问最少需要买多少钱东西;
通过观察所给货币的大小可以发现,只有0.01,0.1,1,10是特例,其他货币之间均只要花费0.01元就能得到B,于是要对这四个数据进行特判
然后观察这四种货币:发现,如果A与B相邻(A一定大于B),那么只需要花费0.01元,即可获得B,如果不相邻,可以先花费0.01元获得与B相邻的货币,然后再花费0.01元即可获得B
#include<stdio.h>using namespace std;int main(){ int t,q=0; scanf("%d",&t); while(++q<=t) { double a,b; scanf("%lf%lf",&a,&b); printf("Case #%lld: ",q); double ans=0.01; if(b==0.01&&a!=0.02)ans=0.02; else if(b==0.1&&a!=0.2)ans=0.02; else if(b==1&&a!=2)ans=0.02; else if(b==10&&a!=20)ans=0.02; printf("%.2lf\n",ans); } return 0;}
阅读全文
0 0
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- UVALive
- JProfiler入门使用教程—Eclipse集成
- Open Live Writer 博客书写工具配置(针对CSDN博客)
- okhttp简单封装+使用
- ≪统计学习精要(The Elements of Statistical Learning)≫课堂笔记(二)
- hdu 5982(16青岛现场赛)Relic Discovery水题
- UVALive
- hello world
- Maven学习总结
- 用Aspose.Cells.dll从Excel读取数据到DataSet
- 读写excel文件
- Hadoop学习笔记(二)HDFS
- 用可重用的链表模块来实现命令行菜单小程序V2.5
- MySQL优化必须调整的10项配置
- 快速解决vs2017应用C++ windows desktop application模板时中文乱码问题