Problem A: 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


题意:旧方式:起步价10元,大于三公里2元/公里,大于十公里的2.5元/公里,等待费2元/5min,最后加1元给司机做额外汽油费。新方式:起步价11元,大于三公里2.5元/公里,大于十公里的3.75元/公里,等待费2.5元/4min。比较两种收费方式,算出相同里程的差价。
主要是四舍五入的问题。。。

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 double round(double val) {
 4     return (val> 0.0) ? floor(val+ 0.5) : ceil(val- 0.5);
 5 }
 6 int main() {
 7     int T;
 8     cin>>T;
 9     while(T--) {
         double d,t;
         double s1=,s2=;
         cin>>d>>t;
         s1+=*t/;
         s2+=2.5*t/;
         if(d>&&d<=) {
             s1+=*(d-);
             s2+=2.5*(d-);
         } else if(d>) {
             s1+=*+*(d-);
             s2+=2.5*+3.75*(d-);
         }
         double r=round(s2)-round(s1);
         //double r=(int)(s2+0.5)-(int)(s1+0.5);
         printf("%.0f\n",r);
     }
     return ;

27 }


The 9th Zhejiang Provincial Collegiate Programming Contest->Problem A:A - Taxi Fare的更多相关文章

  1. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  3. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial ...

  6. zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504  The 12th Zhejiang Provincial ...

  8. zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...

  9. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)

    Floor Function Time Limit: 10 Seconds      Memory Limit: 65536 KB a, b, c and d are all positive int ...

  10. The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple - L Doki Doki Literature Club

    Doki Doki Literature Club Time Limit: 1 Second      Memory Limit: 65536 KB Doki Doki Literature Club ...

随机推荐

  1. 编译mosquitto出现的问题

    [root@localhost mosquitto-1.3]# make WITH_TLS=no set -e; for d in lib client src; do make -C ${d}; d ...

  2. C# IO操作(五)文件的递归加载

    本篇是一个案例,其核心通过代码展示代码中的递归这个用法,程序的界面如下:

  3. iOS开发——开发者官网注册新设备

    1.第一步登陆苹果开发者中心官网,进入证书栏后如下图:点击All 或者如果是iPhone设备直接点击iPhone也行. 然后点击右上角的[+]号

  4. (转)java:快速文件分割及合并

    文件分割与合并是一个常见需求,比如:上传大文件时,可以先分割成小块,传到服务器后,再进行合并.很多高大上的分布式文件系统(比如:google的GFS.taobao的TFS)里,也是按block为单位, ...

  5. [译]JavaScript检测浏览器前缀

    原文地址: Detect Vendor Prefix with JavaScript 不管浏览器私有前缀的现状如何,我们还是要与之为伴,并且有时候还需要利用它来做一些事情.这些前缀可以用于CSS(比如 ...

  6. XPath 初步讲解

    2016-05-05 XPath是JavaScript 中节点查找手段,ie9以后的版本才支持w3c标准,其他浏览器基本支持.在e8之前的浏览器,通过基于 activeX的xml dom对象实现. 为 ...

  7. spring junit参数

    备忘,以后有时间再写点东西吧.其实自己就没有开始写过. blog地址:http://www.cnblogs.com/shizhongtao/p/3342174.html //spring 配置的路径, ...

  8. IPoilygon转IPoint

    private void 河流面转点ToolStripMenuItem_Click(object sender, EventArgs e) { ESRI.ArcGIS.Geodatabase.IWor ...

  9. L005-oldboy-mysql-dba-lesson05

    L005-oldboy-mysql-dba-lesson05 在线改表工具:pt-onine-schema-change 来自为知笔记(Wiz)

  10. ▲▲▲▲▲▲▲▲▲▲▲yum源的配置(本地和ftp)▲▲▲▲▲▲▲▲▲▲▲▲▲v

    ★★★★★★★★★★★★★★★本机yum源★★★★★★★★★★★★★★★★ 1. 首先把DVD里的OS镜像mount处理,如果插入光驱自动mount的话,一般在/media下面,比如RHEL_6.3 ...