The 9th Zhejiang Provincial Collegiate Programming Contest->Problem A:A - Taxi Fare
题意:旧方式:起步价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的更多相关文章
- 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 ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...
- 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 ...
- zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time
http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 【程序员的SQL金典】笔记(第6章~第11章)
第六章 索引与约束 1.索引用来提高数据的检索速度,而约束则用来保证数据的完整性. 2.创建索引 创建索引的SQL 语句是CREATE INDEX,其语法如下: CREATE INDE ...
- 换模板,修改了一下css,清新多了~
基于elf template,改了一下字体颜色和背景.布局的宽度: 博客园修改css真是方便,如果可以直接编辑template代码就更赞了- 不过相对前端web自定义,我更在意后端的服务器是否稳定: ...
- Android代码内存优化建议-OnTrimMemory优化
原文 http://androidperformance.com/2015/07/20/Android代码内存优化建议-OnTrimMemory优化/ OnTrimMemory 回调是 Androi ...
- response小结(四)
1.发送http头,控制浏览器定时刷新网页(REFRESH). package com.yyz.response; import java.io.IOException; import javax.s ...
- sql常识-union
SQL UNION 操作符 UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的 SELECT 语句必须拥有相同数量的列.列也必须拥有相似的数据类型.同时,每 ...
- jQuery API 3.1.0 速查表-打印版
jQuery API 3.1.0 速查表-打印图,(API来自:http://jquery.cuishifeng.cn/index.html)
- DDL_数据库模式定义语言
2014年11月22日 15:53:24 DDL 定义 define 概念:是用于描述数据库中要存储的现实世界实体的语言.一个数据库模式包含该数据库中所有实体的描述定义. ...
- CSS3单位
em 做前端的应该对em不陌生,不是什么罕见的单位,是相对单位,参考物是父元素的font-size,具有继承的特点.如果字体大小是16px(浏览器的默认值),那么 1em = 16px. 不过,这样使 ...
- Responsive设计——不同设备的分辨率写法
1.1024px显屏 @media screen and (max-width : 1024px) { /* 样式写在这里 */ } 2.800px显屏 @media screen and (max- ...
- laravel扩展Debugbar
github地址:https://github.com/barryvdh/laravel-debugbar