http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3600

Taxi Fare


Time Limit: 2 Seconds      Memory Limit: 65536 KB

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

Author: WU, Zejun
Contest: The 9th Zhejiang Provincial Collegiate Programming Contest

分析:

题目要求第二种收费方式比第一种多多少钱,直接计算即可。

需要注意浮点数的操作。

AC代码:

 #include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
#include<iostream>
#include<stack>
#include<map>
#include<cmath>
#include<string>
using namespace std;
double method1(double x1, double x2){
double cost = ;
if(x1 > 3.0) {
if(x1 <= 10.0){
cost += (x1-3.0)*2.0;
}
else{
cost += 7.0*2.0+(x1-10.0)*3.0;
}
}
cost += (2.0/5.0)*x2;
return cost;
}
double method2(double x1, double x2){
double cost = ;
if(x1 > 3.0){
if(x1 <= 10.0){
cost += (x1-3.0)*2.5;
}
else{
cost += 7.0*2.5+(x1-10.0)*3.75;
}
}
cost += (2.5/4.0)*x2;
return cost;
}
int main(){
int n;
double road, wait;
scanf("%d", &n);
while(n--){
scanf("%lf%lf", &road, &wait);
double ans1 = method1(road, wait);
double ans2 = method2(road, wait);
int sum1 = floor(ans1+0.5);
int sum2 = floor(ans2+0.5);
printf("%d\n", sum2-sum1);
}
return ;
}

zjuoj 3600 Taxi Fare的更多相关文章

  1. 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 ...

  2. [ACM_数学] Taxi Fare [新旧出租车费差 水 分段函数]

    Description Last September, Hangzhou raised the taxi fares. The original flag-down fare in Hangzhou ...

  3. 2012-2014 三年浙江 acm 省赛 题目 分类

    The 9th Zhejiang Provincial Collegiate Programming Contest A    Taxi Fare    25.57% (166/649)     (水 ...

  4. 使用ML.NET进行自定义机器学习

    ML.NET是Microsoft最近发布的用于机器学习的开源,跨平台,代码优先的框架.尽管对我们来说是一个新的框架,但该框架的根源是Microsoft Research,并且在过去十年中已被许多内部团 ...

  5. A cost-effective recommender system for taxi drivers

    一个针对出租车司机有效花费的推荐系统 摘要 GPS技术和新形式的城市地理学改变了手机服务的形式.比如说,丰富的出租车GPS轨迹使得出做租车领域有新方法.事实上,最近很多工作是在使用出租车GPS轨迹数据 ...

  6. Flink入门训练--以New York City Taxi为例

    最近在学Flink,准备用Flink搭建一个实时的推荐系统.找到一个好的网站(也算作是flink创始者的官方网站),上面有关于Flink的上手教程,用来练练手,熟悉熟悉,下文仅仅是我的笔记. 1. 数 ...

  7. fare|gave it away|catch a glimpse |involve|rip|eternalstiff|

    N-COUNT 旅费;路费;车费A fare is the money that you pay for a journey that you make, for example, in a bus, ...

  8. 【HDU1960】Taxi Cab Scheme(最小路径覆盖)

    Taxi Cab Scheme Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  9. poj 2060 Taxi Cab Scheme (二分匹配)

    Taxi Cab Scheme Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 5710   Accepted: 2393 D ...

随机推荐

  1. Java笔试面试题二(常考问答)转

    1.说出ArrayList,Vector, LinkedList的存储性能和特性 ArrayList 和Vector都是使用数组方式存储数据,此数组元素数大于实际存储的数据以便增加和插入元素,它们都允 ...

  2. 【转】如何使php的MD5与C#的MD5一致?

    有c#生成MD5的代码如下: class CreateMD5 { static void Main(string[] args) { string source = "提问指南"; ...

  3. QOS

    QoS控制原理 · 基于设备的QoS保障技术——CAC· 基于优先级设置的QoS保障技术· 基于减小抖动的QoS保障-Jitter BufferIP传输在时延.抖动.丢包率方面的性能不及TDM传输,而 ...

  4. Android App罕见错误和优化方案

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 1.App如果被定义一个有参数构造函数,那么需要再定义一个无参数的,如果不则会在某些情况下初始化失败 ...

  5. Python之集合(set)

    一种语言它越便捷,开发效率越高,初学阶段就会越困难.因为语言的设计者帮你造了大量的轮子,你就要掌握如何使用这些轮子.所以,对初学Python来说,记忆的东西很多. 进入正题. 集合就像是抛弃了值(va ...

  6. zepto源码--isEmptyObject,isNumeric,inArray,trim--学习笔记

    1.isEmptyObject,判断对象是否为空对象的函数 定义变量name,遍历传入对象的属性name,如果存在任何属性,则返回false,判定传入的参数为非空对象,否则即为空对象. 2.isNum ...

  7. 将java.util.Date类型转换成json时,使用JsonValueProcessor将date转换成希望的类型

    问题描述: java里面时间类型转换成json数据就成这样了: "createTime":{"date":30,"day":3," ...

  8. Fatal error: Cannot redeclare tran() (previously declared in

    解决方法如下: 1.你该段源码里面是不是有include 或者require 之类的包含其他文件函数 包含的文件里已经有 函数 nw() 的定义 而这段代码里又有nv()的定义 所以出现redecla ...

  9. Sparse Graph---hdu5876(set+bfs+补图求最短路)

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5876 题意:有一个含有n个点的无向图,已知图的补图含有m条边u, v:求在原图中,起点s到 ...

  10. Quartz的配置文件quartz.properties详解

    配置 quartz.properties 文件 文件 quartz.properties 定义了 Quartz 应用运行时行为,还包含了许多能控制 Quartz 运转的属性.这个文件应该放在class ...