POJ 1326 Mileage Bank
来源:互联网 发布:淘宝窗帘价格与图片 编辑:程序博客网 时间:2024/05/01 23:34
Mileage Bank
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 12375 Accepted: 5158
Description
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.
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.
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 Y1-500 miles 500 miles500+ 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.
Input
The 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.
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
Output the summary of ACMPerk mileages for each test case, one per line.
Sample Input
Beijing Tokyo 1329 FShanghai Wuhan 433 Y0#
Sample Output
3158
Hint
When calculate bonus ,be sure you rounded x.5 up to x+1
Source
Beijing 2002
解题思路:水水更健康,只是要注意商务舱的里程数要分奇偶两种情况讨论。
#include<iostream>using namespace std;int fee;void calculate(int m,char C){switch(C){case 'F':fee+=2*m;break;case 'B':if(m%2) fee+=(m+m/2+1);elsefee+=(m+m/2);break;case 'Y':if(m<500)fee+=500;elsefee+=m;break;}}int main(){char S1[50],S2[50],Class;int mile;fee=0;while(cin>>S1){if(S1[0]=='#')break;else if(S1[0]=='0') {cout<<fee<<endl;fee=0; }else{cin>>S2>>mile>>Class;calculate(mile,Class);}}return 0;}
- POJ 1326 Mileage Bank
- POJ 1326 Mileage Bank
- poj 1326 Mileage Bank
- POJ 1326 Mileage Bank
- poj 1326 Mileage Bank【四舍五入】
- POJ 1326 Mileage Bank 笔记
- POJ 1326 Mileage Bank
- POJ 1326 Mileage Bank (,四舍五入法)
- POJ 1326 Mileage Bank(水~)
- 1326 Mileage Bank
- Mileage Bank
- Mileage Bank
- POJ 1326 Mileage Bank(我的水题之路——模拟,四舍五入)
- pku1326 - Mileage Bank
- FZU 1116 Mileage Bank
- poj1326(Mileage Bank)
- zoj 1365 Mileage Bank
- POJ1326浅析------Mileage Bank
- RailsCasts中文版,#14 Performing Calculations on Models 利用模型自带的统计功能
- Eclipse快捷键 10个最有用的快捷键
- Java多线程
- JM8.6中的一个重要结构体NALU_t的定义、分配和释放
- 架构师面试题1
- POJ 1326 Mileage Bank
- HOJ 1688 Speed Limit
- (4)AT&T汇编笔记
- 大端(Big Endian)、小端(Little Endian)存储模式名字的来历
- js事件驱动机制 浏览器兼容处理
- Kademlia 协议原理简介
- HOJ 1685 Flow Layout
- 带有边框的ListView和item
- 交叉染色法