[ACM_数学] Taxi Fare [新旧出租车费差 水 分段函数]
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 [新旧出租车费差 水 分段函数]的更多相关文章
- 使用ML.NET预测纽约出租车费
有了上一篇<.NET Core玩转机器学习>打基础,这一次我们以纽约出租车费的预测做为新的场景案例,来体验一下回归模型. 场景概述 我们的目标是预测纽约的出租车费,乍一看似乎仅仅取决于行程 ...
- 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 ...
- Android新旧版本Notification
Android新旧版本Notification 在notification.setLatestEventInfo() 过时了 以前: NotificationManager mn = (Notific ...
- Matlab神经网络函数newff()新旧用法差异
摘要 在Matlab R2010a版中,如果要创建一个具有两个隐含层.且神经元数分别为5.3的前向BP网络,使用旧的语法可以这样写: net1 = newff(minmax(P), [5 3 1]); ...
- zjuoj 3600 Taxi Fare
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3600 Taxi Fare Time Limit: 2 Seconds ...
- Flex布局新旧混合写法详解(兼容微信)
原文链接:https://www.usblog.cc/blog/post/justzhl/Flex布局新旧混合写法详解(兼容微信) flex是个非常好用的属性,如果说有什么可以完全代替 float 和 ...
- 浅谈 angular新旧版本问题
一直在学习angularJs,之前用的版本比较老,前些天更新了一下angularJs的版本,然后发现了一些问题,希望和大家分享一下. 在老的版本里控制器直接用函数定义就可以 比如: 在angularJ ...
- css弹性盒子新旧兼容
前言:本篇随笔是对弹性盒子有了解的人来写的这篇文章,具体属性产生的效果这里不做说明,基础的东西去查文档.这里只是总结. 时至今日,css3的flex弹性盒子在移动端基本上都是支持的,但不排除有些些低版 ...
- spring加载配置新旧方式对比
老方式 1.首先要配置配置文件,如beans.xml,内容如下: <?xml version="1.0" encoding="UTF-8"?> &l ...
随机推荐
- zk源码环境搭建
zk不是使用maven管理的. 将zk的src下的代码导入eclipse,lib下的jar包导入工程. QuorumPeerMain类的main方法是入口,启动了zk的server,参数是conf文件 ...
- 记录今天学习python中for与while循环针对break和continue的用法
python中有两个主要的循环for与while,其中针对这两个循环有两种不同的中断用法break与continue. 首先先看下面的循环代码: 1: for i in range(10):#变量i带 ...
- [2015hdu多校联赛补题]hdu5324 Boring Class
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5324 题意:给你一个二维的序列,让你找出最长的第一维升第二维降的子序列(如果多个答案,输出字典序最小) ...
- Swift3.0基础语法学习<二>
对象和类: // // ViewController2.swift // SwiftBasicDemo // // Created by 思 彭 on 16/11/15. // Copyright © ...
- 开发Android应用怎么更改LOGO图标
开发安卓应用怎么更改LOGO图标,我们知道我们开发安卓程序的时候,都需要给他整一个logo,一般开发程序都会自动一个图标,我们怎么给他更换自己想要的logo图标,之前大家看过我们写的怎么安装程序到虚拟 ...
- WPF 获得鼠标相对于屏幕的位置,相对于控件的位置
相对于屏幕的位置 第一步: /// <summary> /// 用于获得鼠标相对于屏幕的位置 /// </summary> public class Win3 ...
- 实现的一个ajax请求组件 有加载效果
var zhanglei_Ajax = function(url,data,fn){ var str = '<div class="mask" style="pos ...
- 使用 IntraWeb (45) - 活用 IntraWeb
asp.net 刚开始时, 也是拖拉控件, 但后来有了 MVC.xNext. 换个思路使用 IntraWeb 吧: 界面全部用 html+js+css 实现(有些会是用 Delphi 动态生成), 然 ...
- Sql Server 简单查询 异步服务器更新语句
//结构:select 子句 [into 子句] from 子句 [where 子句] [group by 子句] [having 子句] [order by 子句] select dept_c ...
- 远程桌面Default.rdp 中各个参数的含义(转)
存储在 Default.rdp 文件中的设置 默认情况下,将在“我的文档”文件夹中创建 Default.rdp 文件.以下 RDP 设置存储在 Desktop.rdp 文件中: desktopwidt ...