zoukankan      html  css  js  c++  java
  • 省赛热身赛之_Taxi Fare

    原题:

    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

    4
    2 0
    5 2
    7 3
    11 4
    

    Sample Output

    0
    1
    3
    5
     
    分析:
    简单数学题~
    源码:
    #include <stdio.h>
    int main()
    {
        int n;
        scanf("%d",&n);
        while(n--)
        {
            int d,time;
            scanf("%d%d",&d,&time);
            double m1=10.0, m2=11.0;
            if(d>=3)
            {
                if(d>=10)
                {
                    m1+=(14.0+(d-10)*3*1.0);
                    m2+=(17.5+(d-10)*3.75);
                }
                else
                {
                    m1+=((d-3)*2.0);
                    m2+=((d-3)*2.5);
                }
            }
            m1+=(1+time*0.4);
            m2+=((time*2.5)/4);
            int x=m1;
            if(m1-x>=0.5)
                x+=1;
            int y=m2;
            if(m2-y>=0.5)
                y+=1;
            printf("%d\n",y-x);
        }
        return 0;
    }
    
  • 相关阅读:
    区块链入门
    上海美食餐厅
    《OD学hadoop》20160910某旅游网项目实战
    《OD学hadoop》20160904某旅游网项目实战
    《OD学hadoop》20160903某旅游网项目实战
    qt5-自定义类
    qt5-Qt Creator使用
    qt5-QPushButton按钮
    qt5-工程文件的介绍--快捷键
    电路分析-电阻
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3043284.html
Copyright © 2011-2022 走看看