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. HTTP及网络安全

    <图解HTTP>这本书对网络上的主流的协议,做了一个非常透彻明晰的讲解,从http的头信息.响应数据的头信息.状态码的分析.TCP/IP以及网络安全方面的知识,比如https.网络攻击等的 ...

  2. C++ dll调用

    HINSTANCE PH=LoadLibrary(_T("APlayerCaller.dll")); HWND hwnd = AfxGetMainWnd()->m_hWnd; ...

  3. Spring----->projects----->Spring Web Flow

    1.概述(about Spring Web Folw) Spring Web Flow是spring社区一个子project Spring Web Flow builds on Spring MVC ...

  4. Centos上DNS服务器的简单搭建

    1:安装软件包 yum -y install bind bind-chroot bind-utils bind-libs 2:修改配置文件 1): vim  /etc/named.conf 2):在主 ...

  5. android笔记:ViewPager实现界面的滑动

    最近在学习ViewPager实现界面的滑动,拜读了郭神的博客文章,并抽取归纳了自己对ViewPager的理解. ViewPager实现界面滑动的步骤如下: 1.在xml布局内加入控件android.s ...

  6. Python全栈之路4--内置函数--文件操作

    上节重点回顾: 判断对象是否属于某个类,例如: 列表中有个数字,但是循环列表判断长度,用len会报错;因为int不支持len,所以要先判断属于某个类,然后再进行if判断. # isinstance(对 ...

  7. 用T-sql 实现Oracle Connect by 的功能

    ; with subDepartment as ( select BesonDepartmentID, DepartmentName, ParentBesonDepartmentID, 1 as Hi ...

  8. Errors occurred during the build. Errors running builder 'JavaScript Validator' on project 'XXX'.

    Errors occurred during the build. Errors running builder 'JavaScript Validator' on project 'XXX'.   ...

  9. c#开发Mongo笔记第六篇

    之前写的五篇比较得到了大家的积极反馈,也有个别高手对我写我写出的代码进行了指教. 其中提到的我写的查询方法性能有问题,我想了想,如果mongo不是延时加载的话,那我的查询就真的有问题了,就成了查询出来 ...

  10. 今天想用jquery来实现div的拖放功能

    html5标签.拖放(Drag 和 drop)是 HTML5 标准的组成部分. 步骤一:首先设置标签可以被拖 draggable="true" 步骤二:选取被拖的标签,和要放置被拖 ...