zoj3600(暴力模拟)

Taxi Fare
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
好坑的一道题,一开始一直用差值做,到最后再四舍五入。。显然不对,一直WA,后来看了题解才意识到要分开四舍五入。。。。太菜了

#include <bits/stdc++.h>
using namespace std;
int main()
{
   
    int t,a,b;
    while(scanf("%d",&t)!=EOF)
    {
   
        while(t--)
        {
   
            scanf("%d %d",&a,&b);
            double s1=0,s2=0;
            if(a>3&&a<=10)
            {
   
                s1+=(a-3)*2.0;
                s2+=(a-3)*2.5;
            }
            else if(a>10)
            {
   
                s1+=7*2.0+(a-10)*3;
                s2+=7*2.5+(a-10)*3.75;
            }
            s1+=(b/5.0)*2.0;
            s2+=(b/4.0)*2.5;
            int p=(int)(s1+0.5);
            int q=(int)(s2+0.5);
            if(p>q)
                cout<<p-q<<'\n';
            else
                cout<<q-p<<'\n';
        }
    }
    return 0;
}

全部评论

相关推荐

05-12 11:09
已编辑
门头沟学院 后端
已注销:没必要放这么多专业技能的描述。这些应该是默认已会的,写这么多行感觉在凑内容。项目这块感觉再包装包装吧,换个名字,虽然大家的项目基本都是网上套壳的,但是你这也太明显了。放一个业务项目,再放一个技术项目。技术项目,例如中间件的一些扩展和尝试。
简历中的项目经历要怎么写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务