Taxi Fare

来源:互联网 发布:mac ps字体包下载 编辑:程序博客网 时间:2024/04/28 14:02

Taxi Fare

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 26   Accepted Submission(s) : 14

Font: Times New Roman | Verdana | Georgia

Font Size:  

Problem 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 multipletest cases. The first line of input is an integer T ≈ 10000 indicatingthe number of test cases.
Each test case containstwo integers 1 ≤ d ≤ 1000 and 0 ≤ t ≤ 300.

Output

For eachtest case, output the answer as an integer.

Sample Input

42 0 5 2 7 311 4

Sample Output

0 1 3 5
#include <stdio.h>#include <stdlib.h>#include <cmath>int main(){    int m,d,t;    float s1,s,s2;    scanf("%d",&m);    while (m--)    { s=0;        scanf("%d %d",&d,&t);        if (d<=3)        {            s1=11+0.4*t;            s2=11+0.625*t;        }         if(d>3&&d<=10)        {            s1=11+0.4*t+(d-3)*2;            s2=11+0.625*t+(d-3)*2.5;        }         if(d>10)        {            s1=11+0.4*t+7*2+(d-10)*3;            s2=11+0.625*t+7*2.5+(d-10)*3.75;        } int x=s1; if(s1-x>=0.5) x+=1; int y=s2; if (s2-y>=0.5) y+=1; x=abs(x-y);        printf("%d\n",x);    }return 0;}
原创粉丝点击