ZOJ 3600 Taxi Fare (细节题)
2016-04-19 20:39
381 查看
Description
Last September, Hangzhou raised the taxi fares.
The original flag-down fare in Hangzhou was 10 yuan, plusing 2 yuan per kilometer after the first 3km and 3 yuan per kilometer after 10km. The waiting fee was 2 yuan per five minutes. Passengers need to pay extra 1 yuan as the fuel surcharge.
According to new prices, the flag-down fare is 11 yuan, while passengers pay 2.5 yuan per kilometer after the first 3 kilometers, and 3.75 yuan per kilometer after 10km. The waiting fee is 2.5 yuan per four minutes.
The actual fare is rounded to the nearest yuan, and halfway cases are rounded up. How much more money does it cost to take a taxi if the distance is d kilometers and the waiting time is t minutes.
Input
There are multiple test cases. The first line of input is an integer T ≈ 10000 indicating the number of test cases.
Each test case contains two integers 1 ≤ d ≤ 1000 and 0 ≤ t ≤ 300.
Output
For each test case, output the answer as an integer.
Sample Input
Sample Output
思路: 注意不要直接做单价的差值,那样会wrong到死.... The actual fare is rounded to the nearest yuan, and halfway cases are rounded up
这句话很关键啊!!!!
Last September, Hangzhou raised the taxi fares.
The original flag-down fare in Hangzhou was 10 yuan, plusing 2 yuan per kilometer after the first 3km and 3 yuan per kilometer after 10km. The waiting fee was 2 yuan per five minutes. Passengers need to pay extra 1 yuan as the fuel surcharge.
According to new prices, the flag-down fare is 11 yuan, while passengers pay 2.5 yuan per kilometer after the first 3 kilometers, and 3.75 yuan per kilometer after 10km. The waiting fee is 2.5 yuan per four minutes.
The actual fare is rounded to the nearest yuan, and halfway cases are rounded up. How much more money does it cost to take a taxi if the distance is d kilometers and the waiting time is t minutes.
Input
There are multiple test cases. The first line of input is an integer T ≈ 10000 indicating the number of test cases.
Each test case contains two integers 1 ≤ d ≤ 1000 and 0 ≤ t ≤ 300.
Output
For each test case, output the answer as an integer.
Sample Input
4 2 0 5 2 7 3 11 4
Sample Output
0 1 3 5
思路: 注意不要直接做单价的差值,那样会wrong到死.... The actual fare is rounded to the nearest yuan, and halfway cases are rounded up
这句话很关键啊!!!!
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { int T,i,j,d,m,ans1,ans2; double t1,t2; scanf("%d",&T); while(T--) { t1=t2=0; scanf("%d%d",&d,&m); if(d>10) { t1+=3.0*(d-10); t2+=3.75*(d-10); d=10; } if(d>3) { t1+=2.0*(d-3); t2+=2.5*(d-3); } t1+=0.4*m; t2+=0.625*m; ans1=(int)(t1+0.5); ans2=(int)(t2+0.5); // printf("%lf %lf\n",t1,t2); printf("%d\n",ans2-ans1); } return 0; }
相关文章推荐
- JVM内存回收机制简述
- 双向循环链表的头插、中插、尾插、删除、逆序顺序显示(C++实现)
- matlab中 rand和 randn的区别
- OK6410利用矢量中断通过按键控制LED灯
- 从零开始写一个Tomcat(壹)
- 【java项目实战】一步步教你使用MyEclipse搭建java Web项目开发环境(一)
- ZOJ 3210 A Stack or A Queue?【模拟】
- 在ViewPager实现属性动画(包含:怎样获取手机屏的宽高)
- 1016
- 架构设计:系统间通信——ActiveMQ集群方案(上)
- 检查分类覆盖方法
- 【java读书笔记】——java的异常处理
- 【java读书笔记】——Collection集合之六大接口(Collection、Set、List、Map、Iterator和Comparable)
- oj计算某一天是该年中的第几天
- 【Android测试】【随笔】Bugtags初体验
- 测试作业
- hdu 5018 Revenge of Fibonacci
- Lua math库
- PnPCapabilities阻止自动关闭网卡电源
- select、poll、epoll区别对比