题目描述
某市的出租车共分A B两种车型,这两种车型的计价标准如下:
A型出租车:
起步价8元/2.5公里,超出2.5公里的1.3元/公里,不足1公里按1公里计算,乘车时间超出5分钟的部分、每分钟加收0.4元。
B型出租车:
起步价9元/2.5公里,超出2.5公里的1.5元/公里,不足1公里按1公里计算,乘车时间超出5分钟的部分、每分钟加收0.6元。
现给出乘车总路程和乘车总时间,请帮忙计算乘车费用
输入格式
第一行,一个字母A或者B,表示出租车的种类
第二行,有两个用空格分隔的数值,第一个数为最多一个小数位的浮点数,表示总乘车路程,第二个为整数,表示乘车总时间
输出格式
一行,一个正整数表示乘车费用(四舍五入)
输入输出样例
输入样例1:
A 2.6 6
输出样例1:
10
说明
乘车路程和乘车时间都在100内
【耗时限制】1000ms 【内存限制】128MB
代码
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<sstream>
using namespace std;
int main() {
char ch;
double s, sum = 0;
int t;
scanf("%c %lf %d", &ch, &s, &t);
if (ch == 'A') {
if (s <= 2.5) {
sum += 8;
} else {
sum = 8 + int(s + 0.9 - 2.5) * 1.3;
}
if (t > 5) {
sum += (t - 5) * 0.4;
}
} else {
if (s <= 2.5) {
sum += 9;
} else {
sum = 9 + int(s + 0.9 - 2.5)*1.5;
}
if (t > 5) {
sum += (t - 5) * 0.6;
}
}
printf("%d",int(sum+0.5));
return 0;
}