ZOJ 3600 Taxi Fare
来源:互联网 发布:美联储资产负债表数据 编辑:程序博客网 时间:2024/05/11 22:28
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
42 05 27 311 4
Sample Output
0135
题目大意:有两种打车收费的情况,输出两种的差值,但是需要注意的是:先四舍五入后减还是先减后四舍五入呢???一开始以为是先减后四舍五入,但是WA了.....由此可知是先四舍五入后减:
#include<iostream>using namespace std;int main(){ int n; cin>>n; int d,t; while(n--) { cin>>d>>t; double sum1=0; double sum2=0; if(d<=3) { sum1=11; sum2=11; } else if(d>3&&d<=10) { sum1=11+2*(d-3); sum2=11+2.5*(d-3); } else { sum1=25+(d-10)*3; sum2=28.5+(d-10)*3.75; } sum1+=(t*1.0)/5*2; sum2+=(t*1.0)/4*2.5; int sum11,sum22; if((sum1-(int)(sum1))>=0.5) sum11=(int)(sum1)+1; else sum11=(int)(sum1); if((sum2-(int)(sum2))>=0.5) sum22=(int)(sum2)+1; else sum22=(int)(sum2); cout<<sum22-sum11<<endl; /*double sum=sum2-sum1; int sum3=(int)(sum); double a=sum-sum3; if(a>=0.5) cout<<sum3+1<<endl; else cout<<sum3<<endl;*/ } return 0;}
- zoj 3600 Taxi Fare
- ZOJ 3600 Taxi Fare
- ZOJ 3600 Taxi Fare
- ZOJ 3600 Taxi Fare
- ZOJ 3600 Taxi Fare
- ZOJ 3600Taxi Fare
- zoj 3600 Taxi Fare
- ZOJ 3600 Taxi Fare(模拟)
- ZOJ 3600【Taxi Fare】模拟
- ZOJ 3600Taxi Fare(模拟)
- ZOJ 3600 Taxi Fare【模拟】
- ZOJ 3600 Taxi Fare(数学啊)
- ZOJ Problem Set - 3600||Taxi Fare
- ZOJ 3600 Taxi Fare (细节题)
- ZOJ 3600 Taxi Fare (数学)
- ZOJ 3600 Taxi Fare(模拟)
- Z0J 3600 Taxi Fare
- Taxi Fare
- HDU 4593 Robot
- QT重装后出现的问题
- Linux是什么?
- Android开发ListView之BaseExpandableListAdapter
- 笑傲面试和简历编写
- ZOJ 3600 Taxi Fare
- Nginx
- 好看的常用背景色RGB
- JSON解析与序列化
- html js的各种触发事件效果
- 一个家庭幸不幸福,80%以上取决于女主人。有一种女人嫁给谁都幸福
- Timer异常停止后导致任务终止的解决方法
- Latex强制图片位置
- Java 中的继承