ZOJ 3600【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 <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
       double d,w;
        scanf("%lf%lf",&d,&w);
        double sum1=0,sum2=0;
        //先计算起步价
        sum1+=10;
        sum2+=11;
        d=d-3;
        if(d>0&&d<=7)//大于3
        {
            sum1+=d*2;
            sum2+=d*2.5;
        }
        else if(d>7)
        {
            sum1+=7*2;
            sum2+=7*2.5;
            d-=7;
            sum1+=d*3;
            sum2+=d*3.75;

        }
         sum1+=w*0.4;
         sum2+=w*0.625;
         sum1+=1;
         int a,b;
         a=sum1;
         b=sum2;
         if((sum1-a)>=0.5)
            a=a+1;
         if((sum2-b)>=0.5)
            b=b+1;
        //四舍五入
         printf("%d\n",b-a);


    }
    return 0;
}


你可能感兴趣的:(ZOJ 3600【Taxi Fare】模拟)