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;
}

全部评论

相关推荐

预计下个星期就能开奖吧,哪位老哥来给个准信
华孝子爱信等:对接人上周说的是这周
点赞 评论 收藏
分享
10-17 16:07
门头沟学院 Java
牛牛大你18号:在汇报,突然弹出来,,领导以为我在准备跳槽,刚从领导办公室谈心出来
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务