首页 > 学院 > 开发设计 > 正文

ZOJ3600-Taxi Fare

2019-11-06 09:32:33
字体:
来源:转载
供稿:网友

Taxi Fare

Time Limit: 2 Seconds      Memory Limit: 65536 KB

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

42 05 27 311 4

Sample Output

0135
Author: WU, ZejunContest: The 9th Zhejiang Provincial Collegiate Programming Contest

题意:求出两种计价方式的差值

解题思路:四舍五入处理时候直接在double数上加0.5再向下取整就好

#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <vector>#include <set>#include <stack>#include <map>#include <climits>using namespace std;int main(){    int T;    double d,t,x1,x2;    scanf("%d",&T);    while(T--)    {        scanf("%lf %lf",&d,&t);        x1=x2=11;        x1+=2.5*(t/4);        x2+=2.0*(t/5);        if(d>3&&d<=10)        {            x1+=(d-3)*2.5;            x2+=(d-3)*2.0;        }        else if(d>10)        {            x1+=((7*2.5)+(d-10)*3.75);            x2+=((7*2.0)+(d-10)*3);        }        x1=(int)(x1+0.5);        x2=(int)(x2+0.5);        printf("%d/n",abs((int)(x1-x2)));    }    return 0;}


上一篇:2017-02-26

下一篇:初中生学习计划

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表