概述
Mileage Bank
Time Limit: 2 Seconds Memory Limit: 65536 KB
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 |
|
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.
Output
Output the summary of ACMPerk mileages for each test case, one per line.
Sample Input
Beijing Tokyo 1329 F
Shanghai Wuhan 433 Y
0
#
Sample Output
3158
Source: Asia 2002, Beijing (Mainland China)
Regionals 2002 >> Asia - Beijing
问题链接:POJ1326 ZOJ1365 UVALive2524 Mileage Bank
问题描述:(略)
问题分析:
简单模拟题,按题意模拟即可,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)
AC的C++语言程序如下:
/* POJ1326 ZOJ1365 UVALive2524 Mileage Bank */
#include <iostream>
using namespace std;
const int M = 500;
int main()
{
ios::sync_with_stdio(false);
string s1, s2;
int mile, tot = 0;
char c;
while(cin >> s1 && s1[0] != '#') {
if(s1[0] == '0') {
cout << tot << endl;
tot = 0;
} else {
cin >> s2 >> mile >> c;
if(c == 'F')
tot += mile * 2;
else if(c == 'B')
tot += mile + (mile + 1) / 2;
else if(c == 'Y') {
if(mile >= M)
tot += mile;
else if(mile >= 1 && mile <= M)
tot += M;
}
}
}
return 0;
}
最后
以上就是天真黑米为你收集整理的POJ1326 ZOJ1365 UVALive2524 Mileage Bank【模拟】的全部内容,希望文章能够帮你解决POJ1326 ZOJ1365 UVALive2524 Mileage Bank【模拟】所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复