POJ1326解题报告
2012-01-13 14:50
281 查看
Mileage Bank
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 11597 | Accepted: 4814 |
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.
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
Hint
When calculate bonus ,be sure you rounded x.5 up to x+1
看到Discuss中有人评论说,“狗一样的题目”.....犯得着吗,大家都是刷水题的....................................
round库函数可以作四舍五入..蛮方便的..............
#include<stdio.h> #include<string.h> #include<math.h> int licheng=0; int main() { char city[200]; char country[200]; int miles; char tag; float ys; scanf("%s",city); while(strcmp(city,"#")!=0) { licheng=0; while(strcmp(city,"0")!=0) { scanf("%s %d %c",&country,&miles,&tag); if(tag=='F') { licheng+=2*miles; } else if(tag=='B') { licheng+=round(miles*1.5); } else if(tag=='Y') { licheng+=miles>500?miles:500; } scanf("%s",&city); } printf("%d\n",licheng); scanf("%s",city); } system("pause"); return 0; }
相关文章推荐
- poj1326解题报告
- POJ 1658 解题报告
- POJ 2713 肿瘤面积 解题报告
- POJ 2715 谁拿了最多奖学金 解题报告
- poj解题报告
- POJ-1106 Transmitters解题报告
- POJ 1401 Factorial 解题报告
- POJ-1473 There's Treasure Everywhere!解题报告
- POJ 2965 The Pilots Brothers' refrigerator 解题报告
- POJ 1056 解题报告
- POJ 3233 Matrix Power Series 解题报告(子矩阵构造+矩阵快速幂)
- POJ1088 滑雪 解题报告
- poj 1182-食物链解题报告
- POJ 1788 解题报告
- poj 1182 食物链 解题报告
- 归并排序与逆序对问题---(解题报告)POJ1804---Brainman
- poj 2485 解题报告
- POJ 2739(连续素数和) 解题报告
- poj1008"Maya Calendar"解题报告
- POJ3162 解题报告