ZOJ 3600 Taxi Fare (analog)

Source: Internet
Author: User

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

Main topic:
Hangzhou has two kinds of taxi prices, one is three kilometers within 10 yuan, 3~10 kilometers per kilometer of 2 yuan, more than 10 kilometers of the portion of 3 yuan per kilometer, 5 minutes per hour, the need for 2 yuan, but additional pay 1 yuan. Another is three kilometers within 11 yuan, 3~10 kilometers per kilometer of 2.5 yuan, more than 10 kilometers of the portion of 3.75 yuan per kilometer, each 4 minutes need 2.5 yuan. Ask how much money the first is cheaper than the second.

Problem Solving Ideas:
Follow the test instructions simulation again, pay attention to the accuracy problem.

#include <iostream>
#include <cstdio>
using namespace std;
int main ()
{
    int tt,d,t;
    cin>>tt;
    while (tt--)
    {
        cin>>d>>t;
        Double ans1=t*0.4+11,ans2=t*0.625+11;
        if (d>3)
        {
            if (d<=10)
            {
                ans1+=2* (d-3);
                ans2+=2.5* (d-3);
            }
            else
            {
                ans1+=14+3* (d-10);
                ans2+=17.5+3.75* (d-10);
            }
        }
        int ans= (int) (ans2+0.5)-(int) (ans1+0.5);
        cout<<ans<<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.