Mileage Bank

原创 2013年12月03日 09:41:12
题目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
****************************************************************/


题目1484:Mileage Bank

一直AC不过,但感觉逻辑上没有问题?实在不知错在何处。自己写的比较麻烦,找到一个网上的解法,写得比较简洁,而且四舍五入处值得借鉴。 题目描述: Mileage program of ACM ...
  • u012608274
  • u012608274
  • 2017年02月12日 16:38
  • 363

POJ 1326 Mileage Bank (,四舍五入法)

AC好久才成功了; 学会四舍五入法 例如 int ans=ans+(m(int型)*1.0 / 2.0 + 0.5) 话说现在才道这个 string类这么好用; 附上代码 Mileage Ba...
  • i_iphone
  • i_iphone
  • 2013年04月09日 22:34
  • 721

POJ 1326 Mileage Bank

Mileage Bank Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 12375   ...
  • hqu_fritz
  • hqu_fritz
  • 2012年11月24日 23:28
  • 480

ZOJ 1365 Mileage Bank

Mileage Bank Time Limit: 2 Seconds      Memory Limit: 65536 KB Mileage program of ACM (Airline...
  • wpfengqi
  • wpfengqi
  • 2012年08月24日 11:30
  • 167

【九度】题目1484:Mileage Bank

题目1484:Mileage Bank 时间限制:1 秒内存限制:128 兆特殊判题:否提交:261解决:91 题目描述: Mileage program of ACM (Airline of ...
  • u013027996
  • u013027996
  • 2014年05月30日 17:08
  • 769

内存超出 题目1484:Mileage Bank

题目1484:Mileage Bank题目描述: Mileage program of ACM (Airline of Charming Merlion) is really nice for th...
  • u012768474
  • u012768474
  • 2016年09月04日 20:16
  • 98

cuda编程:关于共享内存(shared memory)和存储体(bank)的事实和疑惑

主要是在研究访问共享内存会产生bank conflict时,自己产生的疑惑。对于这
  • linger2012liu
  • linger2012liu
  • 2014年06月20日 20:06
  • 3951

什么是内存BANK

这篇文章来至“脚本之家”。 关于内存Bank的探讨 目前很多人对内存Bank(电脑系统与内存之间数据总线的基本工作单位)都有一种误解,认为单面内存就是单Bank,双面内存就是双Bank的。其实这种观...
  • u011872210
  • u011872210
  • 2016年03月18日 10:29
  • 1093

汽车油耗录入及统计(Gas Mileage)

花了1小时完成了一个小练习,不容易啊!   主要知识点: 1. While循环中使用sentinel(循环退出判断条件)实现indefinite loop(不定循环)。 说简单点,就是只要用户...
  • hpdlzu80100
  • hpdlzu80100
  • 2016年06月17日 00:48
  • 911

OpenCL性能优化实例研究系列2:避免Local Memory Bank Conflicts的两个简单方法

转自:http://hi.baidu.com/fsword73/item/51df1fafe6083e268919d39e 作者:  fsword73 Bank Conflicts 是存储...
  • lucky_greenegg
  • lucky_greenegg
  • 2013年08月15日 22:41
  • 1840
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Mileage Bank
举报原因:
原因补充:

(最多只允许输入30个字)