您的位置:首页 > 其它

ZOJ 1365 Mileage Bank

2012-08-24 11:30 204 查看
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.
[align=center]When you fly ACM[/align]
[align=center]Class Code[/align]
[align=center]You'll earn[/align]
[align=center]First Class[/align]
[align=center]F[/align]
[align=center]Actual mileage + 100% mileage Bonus[/align]
[align=center]Business Class[/align]
[align=center]B[/align]
[align=center]Actual mileage + 50% mileage Bonus[/align]
Economy Class

1-500 miles

500+ miles
[align=center]Y[/align]
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.

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

题意:就是根据class code计算ACMPerk mileages,注意不足500算500
代码:
#include <stdio.h>

#include <string.h>

int main()

{

char name1[200];

char name2[200];

char code;

while(1){

int sum=0,dis;

while(scanf("%s",name1)&&strcmp(name1, "0")!=0&&strcmp(name1, "#")!=0){

scanf("%s",name2);

scanf("%d",&dis);

getchar();

scanf("%c",&code);

if(code=='Y')

{

if(dis<=500)

sum+=500;

else

sum+=dis;

}

if(code=='B')

sum+=1.5*dis;

if(code=='F')

sum+=2*dis;

}

if(strcmp(name1, "#")==0)

break;

printf("%d\n",sum);

}

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: