[ACM_数学] Taxi Fare [新旧出租车费差 水 分段函数]
2014-03-16 15:51
183 查看
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
Sample Output
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 [b]题目大意:新旧2中出租车要价方案,问2次价格相差多少。注意每种价钱要用四舍五入![/b] [b]解题思路:分段函数+每个价钱分别四舍五入相减。 [/b]
#include<iostream> using namespace std; int first(int d,int t){ double sum=11; sum+=2/5.0*t; if(d>3 && d<=10)sum+=2*(d-3); else if(d>10)sum+=(3*(d-10)+7*2); return (int)(sum+0.5); } int second(int d,int t){ double sum=11; sum+=2.5/4*t; if(d>3 && d<=10)sum+=(d-3)*2.5; else if(d>10)sum+=((d-10)*3.75+7*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 0; }
相关文章推荐
- 2014年山东ACM第五届省赛 angry_birds_again_and_again(数学积分)
- 杭电ACM 二 数学求模
- HDOJ--ACM-Steps--2.1.3--Cake(GCD,简单数学)
- 山东省第四届acm.Rescue The Princess(数学推导)
- ACM学习历程—HDU5587 Array(数学 && 二分 && 记忆化 || 数位DP)(BestCoder Round #64 (div.2) 1003)
- ACM 常用几何基本数学公式
- hdu 2441-ACM(Array Complicated Manipulation)(数学)
- 【算法笔记】acm数学基础
- HDU5073 ACM-ICPC亚洲区域赛鞍山赛区现场赛D题 Galaxy 贪心+数学推导
- Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)
- ACM内部函数--数学问题--大数相加
- ACM递推递归练习J 数学黑洞
- B. Coin 数学/组合数 2017 ACM-ICPC 亚洲区(西安赛区)网络赛
- ACM内部函数--数学问题--大数除法和取余
- ACM: 数学题 uva_11137
- ACM数学
- ACM-ICPC 长沙现场赛 C 题 ZOJ3728(为什么我A过的数学题都是水题T_T)
- ACM数学题--转
- 2010 ACM/ICPC 福州赛区 Problem E(数学知识)
- ACM 进阶学习第一课----简单数学问题之同余相关