poj1326解题报告
来源:互联网 发布:订单生产进度跟踪软件 编辑:程序博客网 时间:2024/05/18 00:50
Mileage Bank
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 13705 Accepted: 5713
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
代码:
#include<iostream>
#include<string>
using namespace std;
int main()
{
string st1,st2;
char ch;
int length,sum=0;
while (cin>>st1)
{
if (st1=="0")
{
cout<<fixed<<sum<<endl;
sum=0;
continue;
}
else if (st1=="#") {break;}
else
{
cin>>st2>>length>>ch;
if (ch=='F')
{
length=length*2;
sum+=length;
}
if (ch=='B')
{
sum+=length;
sum+=(length*1.0/2.0+0.5);
}
if (ch=='Y')
{
if (length<500) {length=500;}
sum+=length;
}
}
}
return 0;
}
本题只要注意B时候的四舍五入,在最后结尾时,判断0时需要返回重新输入一次st1,再来判断是否为#,最最重要的返回是一定要把sum的值清0,我找了好久才发现这个小问题,总的来说本题目不难,只需要细心的做下去,应该一次就能a掉~
0 0
- POJ1326解题报告
- poj1326解题报告
- poj1326
- poj1326
- poj1326
- poj1326
- 解题报告
- 解题报告
- 解题报告
- 解题报告
- 解题报告
- 解题报告
- 解题报告
- Antiprime解题报告
- expr解题报告
- 华容道解题报告
- tju解题报告
- zju1062/pku1095解题报告
- coreldraw 双层边框
- 存储过程返回数组对象例子
- Andriod官方文档翻译
- java中方法调用在内存中的体现
- Android系统性能调优工具介绍 .
- poj1326解题报告
- Erlang cowboy 处理简单的HTTP请求
- 使用ConditionalRemoval移除离群点
- lucene工具类-升级索引
- 猎头深度揭秘2014年互联网业薪水行情:互联网已经进入全面20W时代
- adb server is out of date. killing...
- 黑马程序员_Java中字符串解析
- coreldraw 复制填充渐变色
- linux中fork--子进程是从哪里开始运行