ZOJ 3600 Taxi Fare

Source: Internet
Author: User
Tags time limit

Title Link: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3600


Surface:



Taxi Fare time Limit:2 Seconds Memory limit:65536 KB

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


Solving:

Personally think that the problem is very unclear, literally seems to have not said to ask for the difference between the two.

Another thing that may be confusing is the relationship between the starting price and the waiting time, and the final conclusion is: The starting price in 3 km plus the waiting time fee, the other according to the sub-calculation is good.

Take an integer, the operation of the process with floating point, the last add 0.5 to take the whole good.


Code:

#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cstdio>
#include <cstring>
using namespace std;

int main ()
{
    int n,d,t,cost1,cost2;
    cin>>n;
    while (n--)
    {
      cin>>d>>t;
      if (d<=3)
      {
        cost1=11;
        cost1+=t*2.0/5+0.5;
      }
      else
      {
        if (d<=10)
            cost1=10+1+ (d-3) *2+t*2.0/5+0.5;
        else
            cost1=10+1+7*2+3* (d-10) +t*2.0/5+0.5;
      }
          if (d<=3)
          {
            cost2=11;
            cost2+=t*2.5/4+0.5;
          }
          else
          {
             if (d<=10)
               cost2=11+ (d-3) *2.5+t*2.5/4+0.5;
             else
               cost2=11+7*2.5+ (d-10) *3.75+t*2.5/4+0.5;
          }
      cout<<cost2-cost1<<endl;
    }
	return 0;
}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.