2014ACM集训13级PK赛3-Taxi Fare
2014-03-10 22:03
363 查看
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
0135
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
0135
#include <stdio.h> #include <math.h> #include <stdlib.h> int main() { int N; scanf ("%d",&N); while (N--) { int d,t; double ans1,ans2; scanf ("%d%d",&d,&t); if (d <= 3) { ans1 = (double)10 + 1 + 0.4 * t; ans2 = (double)11 + 0.625 * t; }else if (d <= 10) { ans1 = (double)11 + 0.4 * t + (d - 3) * 2; ans2 = (double)11 + 0.625 * t + (d - 3) * 2.5; }else { ans1 = (double)11 + 0.4 * t + 7 * 2 + (d - 10) * 3; ans2 = (double)11 + 0.625 * t + 7 * 2.5 + (d - 10) * 3.75; } int a = ans1 + 0.5,b = ans2 + 0.5; int ans = fabs (a - b); printf ("%d\n",ans); } return 0; }
相关文章推荐
- 2014ACM集训13级PK赛2-Guess the Price
- 2014ACM集训13级PK赛3-Density of Power Network
- 2014ACM集训13级PK赛5-Build The Electric System
- 2014寒假ACM集训13级PK赛-翻转排序
- 2014寒假ACM集训13级PK赛-购买矿石
- 2014寒假ACM集训13级PK赛-最佳拟合直线
- 2014暑假ACM13级一批集训内容
- 2014ACM集训13级PK赛2-Wu Xing
- 2014春季ACM集训_基本算法------F---------Ubiquitous Religions (并查集)
- 2014ACM集训13级PK赛2-Ordinal Numbers
- 2014ACM集训13级PK赛2-Conic Section
- 2014ACM集训13级PK赛3-Draw Something Cheat
- 2014ACM集训13级PK赛2-Kagome Kagome
- 2014ACM集训13级PK赛3-Modular Inverse
- 2014ACM集训13级PK赛4-Second-price Auction
- [直播]2014 PKU ACM暑期集训
- 2014ACM集训13级PK赛2-Javabeans
- 2014ACM集训13级PK赛3-Yet Another Story of Rock-paper-scissors
- 2014ACM集训13级PK赛2-Median
- 2014ACM集训13级PK赛3-Break Standard Weight