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 ...
随机推荐
- JAVA之While语句、Do和For语句
先看While语句和Do While语句,它们有着相同之处,但是也有区别.下面示例While语句.Do While语句和For语句(运行结果是相同的): While语句: public class w ...
- 图片上传即时显示javascript代码
这是基于javascript的一种图片上传即时显示方法,测试结果IE6和火狐浏览器可以正常使用.google浏览器不兼容. 这种方法兼容性比较差,仅供参考,建议使用ajax方法来即时显示图片. 1.首 ...
- 设置In_Memery
alter system set inmemory_size=4G scope=spfile; alter table table_name inmemory; alter table table_n ...
- Swift字典类
在Foundation框架中提供一种字典集合,它是由“键-值”对构成的集合.键集合不能重复,值集合没有特殊要求.键和值集合中的元素可以是任何对象,但是不能是nil.Foundation框架字典类也分为 ...
- Swift协议(Protocol)
协议是为方法.属性等定义一套规范,没有具体的实现. 协议能够被类.结构体等具体实现(或遵守). protocol SomeProtocol { // protocoldefinition goes h ...
- 值类型与引用类型(特殊的string) Typeof和GetType() 静态和非静态使用 参数传递 相关知识
学习大神博客链接: http://www.cnblogs.com/zhili/category/421637.html 一 值类型与引用类型 需要注意的string 是特殊类型的引用类型. 使用方法: ...
- 怎样把SEL放进NSArray里
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3805270.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...
- Sublime Text 破解
引言 放假三天,呆家里把win7换成了win8.1,接着玩起了hyperv,试着装了个windows xp虚拟机,体验很不错.不过对linux系统的支持不怎么样,装了个ubuntu,体验相当差!闲着无 ...
- [java学习笔记]java语言基础概述之内存的划分&堆和栈
1.内存的划分 1.寄存器 cpu处理 2.本地方法区 和所在系统相关 3.方法区 方法加载进内存,其实就是开辟了一块该方法的方法区 方法区中还可以有静态区,用于存放静态变量(类变量) 4.栈内存 5 ...
- Jquery实现简单的分页
转,Jquery实现简单的翻页功能 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " ...