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
这题目有点坑爹,我一开始直接用价格之间相减直接求差,最后再四舍五入,怎么也AC不了。纳闷死了。。。
原来是需要你分别求出两者的价格然后再四舍五入了求差值。
#include <iostream> using namespace std; int main() { int t; cin >> t; while (t--) { int d, t; cin >> d >> t; float sum1=11,sum2=11; sum1 += (2.0 / 5)*t; sum2 += (2.5 / 4)*t; if (d > 3) { if (d <= 10) { sum1 += 2 * (d - 3); sum2 += 2.5 * (d - 3); } else { sum1 += 2 * 7 + 3 * (d - 10); sum2 += 2.5 * 7 + 3.75 * (d - 10); } } int x,y; x = sum1; y = sum2; if (sum1 - x >= 0.5) x++; if (sum2 - y >= 0.5) y++; cout << y - x << endl; } return 0; }
本文介绍了一种计算方法,用于对比杭州出租车费调整前后的费用差异。通过输入行驶距离及等待时间,程序能够准确计算出两种计费方式的差额,并进行合理的四舍五入处理。
1万+

被折叠的 条评论
为什么被折叠?



