Describe
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 dkilometers 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
Source of the topic
http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=4288
The only point of attention to this problem is the topic told to wait for the price, modified before is waiting for 5 minutes 2 yuan, that is, 0.4 yuan per minute, modified is to wait 4 minutes 2.5 yuan, that is, 0.625 yuan per minute.
Perhaps another problem is rounding, direct double int just rounding, not five. Then we can give each double plus 0.5, so double int is rounded.
#include <iostream>
using namespace std;
Const double FT = 0.4;//wait per minute surcharge
Const double LT = 0.625;//fee wait per minute additional charge
int main ()
{
int n;
Double fm,lm;
Double d,t;
cin>>n;
while (n--)
{
fm = 0; lm = 0;
cin>>d>>t;
if (d>10)
{
FM + = 3.0 * (d-10);
LM + = 3.75 * (d-10);
D = ten;
}
if (d>3)
{
FM + = 2.0 * (d-3);
LM + = 2.5 * (d-3);
d = 3;
}
FM + = FT*T;
LM + = lt*t;
int IFM = FM + 0.5;//+0.5 is for rounding
int ilm = LM + 0.5;
Because the starting price of the same is 11 yuan so did not count in
cout<<ilm-ifm<<endl;
}
}