[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 ...
随机推荐
- redis3.0.5集群部署安装详细步骤
Redis集群部署文档(centos6系统) (要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对应的redis节点的ip和端口对应关系如下) ...
- spi controller
http://blog.csdn.net/droidphone/article/details/24353293 http://www.china-cpu.com/supports/article/0 ...
- centos安装mysql5.6的正确姿态
1.准备工作 a)卸载centos默认软件 yum remove mariadb-libs-5.5.35-3.el7.x86_64 b)安装依赖包 yum install -y perl-Module ...
- python--自动删除文件
1.目的:定期自定删除7天前的数据 python脚本如下: #coding=utf-8 import os,time,datetime #需定时删除的目录的上一层路径 data_dir="/ ...
- Java Web的开始学习
今天开始学习Web了,需要的前提技能是 XML ,我还不太熟悉,今天的任务需要熟悉一下 XML-- 输入输出流 I/O 序列化反序列化,也需要看一下,我看这两块会有用到. 任务: ---- ...
- CSS3--响应式布局
一.流式布局 不再使用px作为盒模型布局,而是采用百分比布局宽高,定位等. 公式:目标元素宽度/上下文元素宽度=百分比宽度 目标定位/上下文元素宽度或高度=定位距离(保留5位小数点) 用em/rem来 ...
- 多重背包问题:POJ2392
这是一道完全背包问题,只不过增加了限制条件. 在更新最大值的时候,我注释掉了错误的方式,却不明白为什么是错误的,如果有人看到这篇博客,并且知道为什么那样更新是错误的,请指教,谢谢. 上代码: #inc ...
- iOS UILabel根据字符串长度自动适应宽度和高度
//这个frame是初设的,没关系,后面还会重新设置其size. UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0,0, ...
- Navicat for Oracle 连接oracle 配置
oci.dll 替换为对应oracle版本的oci.dll
- What he did
//记录组内成员具体完成工作情况,格式为:时间-事件-人物 2015-4-19 用户需求分析---主要由韩林编写,国旗,李春伟辅助编写,国旗发布文档至博客 2015-4-22 快速原型---由郭龙东完 ...