Description
Last September, Hangzhou raised the taxi fares.
The original Flag-down fare in Hangzhou is Yuan, plusing 2 yuan per kilometer after the first 3km and 3 yuan per Kilom Eter 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 one yuan, while passengers pay 2.5 yuan per kilometer after the first 3 kilo Meters, 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 was rounded up. How much + does it cost to take a taxi if the distance are d kilometers and the waiting time is t minutes.
Input
There is multiple test cases. The first line of input was an integer t≈10000 indicating the number of test cases.
Each test case contains the integers 1≤d≤1000 and 0≤t≤300.
Output
For each test case, the output of the answer as an integer.
Sample Input
4
2 0
5 2
7 3
11 4
Sample Output
0
1
3
5
Idea: Be careful not to do the difference of unit price directly, that will wrong to die .... The actual fare is rounded to the nearest yuan, and halfway cases was rounded up
This sentence is very important ....
#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;
}