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 题目大意:新旧2中出租车要价方案,问2次价格相差多少。注意每种价钱要用四舍五入!
解题思路:分段函数+每个价钱分别四舍五入相减。
 #include<iostream>
using namespace std;
int first(int d,int t){
double sum=;
sum+=/5.0*t;
if(d> && d<=)sum+=*(d-);
else if(d>)sum+=(*(d-)+*);
return (int)(sum+0.5);
}
int second(int d,int t){
double sum=;
sum+=2.5/*t;
if(d> && d<=)sum+=(d-)*2.5;
else if(d>)sum+=((d-)*3.75+*2.5);
return (int)(sum+0.5);
}
int main(){
int T;cin>>T;
while(T--){
int d,t;
cin>>d>>t;
cout<<second(d,t)-first(d,t)<<'\n';
}return ;
}

[ACM_数学] Taxi Fare [新旧出租车费差 水 分段函数]的更多相关文章

  1. 使用ML.NET预测纽约出租车费

    有了上一篇<.NET Core玩转机器学习>打基础,这一次我们以纽约出租车费的预测做为新的场景案例,来体验一下回归模型. 场景概述 我们的目标是预测纽约的出租车费,乍一看似乎仅仅取决于行程 ...

  2. The 9th Zhejiang Provincial Collegiate Programming Contest->Problem A:A - Taxi Fare

    Problem A: Taxi Fare Time Limit: 2 Seconds Memory Limit: 65536 KB Last September, Hangzhou raised th ...

  3. Android新旧版本Notification

    Android新旧版本Notification 在notification.setLatestEventInfo() 过时了 以前: NotificationManager mn = (Notific ...

  4. Matlab神经网络函数newff()新旧用法差异

    摘要 在Matlab R2010a版中,如果要创建一个具有两个隐含层.且神经元数分别为5.3的前向BP网络,使用旧的语法可以这样写: net1 = newff(minmax(P), [5 3 1]); ...

  5. zjuoj 3600 Taxi Fare

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3600 Taxi Fare Time Limit: 2 Seconds    ...

  6. Flex布局新旧混合写法详解(兼容微信)

    原文链接:https://www.usblog.cc/blog/post/justzhl/Flex布局新旧混合写法详解(兼容微信) flex是个非常好用的属性,如果说有什么可以完全代替 float 和 ...

  7. 浅谈 angular新旧版本问题

    一直在学习angularJs,之前用的版本比较老,前些天更新了一下angularJs的版本,然后发现了一些问题,希望和大家分享一下. 在老的版本里控制器直接用函数定义就可以 比如: 在angularJ ...

  8. css弹性盒子新旧兼容

    前言:本篇随笔是对弹性盒子有了解的人来写的这篇文章,具体属性产生的效果这里不做说明,基础的东西去查文档.这里只是总结. 时至今日,css3的flex弹性盒子在移动端基本上都是支持的,但不排除有些些低版 ...

  9. spring加载配置新旧方式对比

    老方式 1.首先要配置配置文件,如beans.xml,内容如下: <?xml version="1.0" encoding="UTF-8"?> &l ...

随机推荐

  1. VC++ list函数详解

    在使用之前,需要完成两件事: (1)  #include <list> (2)  using namespace std; 声名变量:   list<int>  intlist ...

  2. BSF、BSR: 位扫描指令

    ;BSF(Bit Scan Forward): 位扫描找1, 低 -> 高 ;BSR(Bit Scan Reverse): 位扫描找1, 高 -> 低   找到是 1 的位后, 把位置数给 ...

  3. Jquery easyui中的有效性检查

    使用过程中的一积累,备查. EasyUI 验证框使用方法: //*************************** missingMessage:未填写时显示的信息 validType:验证类型见 ...

  4. Java中abstract的用法

    1,abstract修饰类,会使这个类成为一个抽象类,这个类将不能生成对象实例,可以做为对象变量声明的类型,也就是编译时类型,抽象类就像当于一类的半成品,需要子类继承并覆盖其中的抽象方法. 2,abs ...

  5. POJ 1637 Sightseeing tour (混合图欧拉回路)

    Sightseeing tour   Description The city executive board in Lund wants to construct a sightseeing tou ...

  6. 转贴 IT外企那点儿事完整版

    转贴 IT外企那点儿事完整版 第一章:外企也就那么回儿事(http://www.cnblogs.com/forfuture1978/archive/2010/04/30/1725341.html) 1 ...

  7. mac操作快捷键

  8. [转]初探 PhoneGap 框架在 Android 上的表现

    原文地址:http://topmanopensource.iteye.com/blog/1486929 phonegap是由温哥华的一家小公司研发的多平台的移动开发框架,支持流行的大多数移动设备(iP ...

  9. MVC 路由模块内核原理

    .net网站第一次运行的时候 执行global文件的application_start方法 注册路由信息   RouteConfig.RegisterRoutes(RouteTable.Routes) ...

  10. android studio小技巧

    1. 为了防止乱码,请将 android studio 右下角编码设置成 UTF-8 2. Ctri + Q 查看api 3 Ctri + Shift +U 大小写互换 4 Ctrl + Alt + ...