Mileage Bank

72 篇文章 0 订阅
题目1484:Mileage Bank

时间限制:1 秒

内存限制:128 兆

特殊判题:

提交:158

解决:61

题目描述:

Mileage program of ACM (Airline of Charming Merlion) is really nice for the travelers flying frequently. Once you complete a flight with ACM, you can earn ACMPerk miles in your ACM Mileage Bank depended on mileage you actual fly. In addition, you can use the ACMPerk mileage in your Mileage Bank to exchange free flight ticket of ACM in future.

The following table helps you calculate how many ACMPerk miles you can earn when you fly on ACM.

When you fly ACM       Class Code                                        You'll earn
 
First Class                           F                            Actual mileage + 100% mileage Bonus
 
Business Class                 B                           Actual mileage + 50% mileage Bonus
 
Economy Class                  Y
1-500 miles                                                                               500 miles
500+ miles                                                                           Actual mileage

It's shown that your ACMPerk mileage consists of two parts. One is your actual flight mileage (the minimum ACMPerk mileage for Economy Class for one flight is 500 miles), the other is the mileage bonus (its accuracy is up to 1 mile) when you fly in Business Class and First Class. For example, you can earn 1329 ACMPerk miles, 1994 ACMPerk miles and 2658 ACMPerk miles for Y, B or F class respectively for the fly from Beijing to Tokyo (the actual mileage between Beijing and Tokyo is 1329 miles). When you fly from Shanghai to Wuhan, you can earn ACMPerk 500 miles for economy class and ACMPerk 650 miles for business class (the actual mileage between Shanghai and Wuhan is 433 miles).

Your task is to help ACM build a program for automatic calculation of ACMPerk mileage.

输入:

he input file contains several data cases. Each case has many flight records, each per line. The flight record is in the following format:

OriginalCity DistanceCity ActualMiles ClassCode

Each case ends with a line of one zero.

A line of one # presents the end of the input file.

输出:

Output the summary of ACMPerk mileages for each test case, one per line.

样例输入:
Beijing Tokyo 1329 F
Shanghai Wuhan 433 Y
0
#
样例输出:
3158
提示:

When calculate bonus ,be sure you rounded x.5 up to x+1


#include<iostream>
using namespace std;
 
int main()
{
    char ch;
    string s;
    int m,n=0;
    while(cin>>s)
    {
        if(s=="#")break;
        else if(s=="0")
        {
             cout<<n<<endl;
             n=0;
        }
        else
        {
            cin>>s>>m>>ch;
            if(ch=='F')n+=2*m;
            else if(ch=='B')n+=m+(m+1)/2;
            else if(ch=='Y' && m<=500)n+=500;
            else n+=m;
        }
    }
    return 0;
} 
/**************************************************************
    Problem: 1484
    User: 3011216016
    Language: C++
    Result: Accepted
    Time:10 ms
    Memory:1520 kb
****************************************************************/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值