UVa145 Gondwanaland Telecom
Time limit: 3.000 seconds
限时:3.000秒
Problem
问题
Gondwanaland Telecom makes charges for calls according to distance and time of day. The basis of the charging is contained in the following schedule, where the charging step is related to the distance:
冈瓦纳电信公司依照一天中的时段和通话距离来收取话费。下表列出了基本通话费方案。当中话费阶段是按距离远近安排的。
|
Charging Step (distance) |
Day Rate 8am to 6pm |
Evening Rate 6pm to 10pm |
Night Rate 10pm to 8am |
| A | 0.10 | 0.06 | 0.02 |
| B | 0.25 | 0.15 | 0.05 |
| C | 0.53 | 0.33 | 0.13 |
| D | 0.87 | 0.47 | 0.17 |
| E | 1.44 | 0.80 | 0.30 |
All charges are in dollars per minute of the call. Calls which straddle a rate boundary are charged according to the time spent in each section. Thus a call starting at 5:58 pm and terminating at 6:04 pm will be charged for 2 minutes at the day rate and for
4 minutes at the evening rate. Calls less than a minute are not recorded and no call may last more than 24 hours.
全部话费都是依照通话的分钟数累计的。
若一次通话跨越了两个时段,则分别依照在各时段内的通话时间和费率进行收费。比方一次通话由晚5:58開始到晚6:04结束,则按2分钟的白天通话和4分钟的夜晚通话费率计算。通话少于1分钟的不计费,最长的通话不会超过24小时。
Write a program that reads call details and calculates the corresponding charges.
写一个程序读取全部的通话信息并计算相应的话费。
Input and Output
输入与输出
Input lines will consist of the charging step (upper case letter 'A'..'E'), the number called (a string of 7 digits and a hyphen in the approved format) and the start and end times of the call, all separated by exactly one blank. Times are recorded as hours
and minutes in the 24 hour clock, separated by one blank and with two digits for each number. Input will be terminated by a line consisting of a single #.
输入由多行组成。每一行数据都包含:话费阶段(大写字母“A”到“E”),拨出的号码(一个7位数组和横线组成的字符串),通话的開始和结束时间。这些数据间都由空格隔开。
时间均由24小时制的小时和分钟表示。之间由一个空格隔开,每一个数字都有两位数(译注:不足两位的前面补零)。仅仅有一个#号的单独一行表示输入结束。
Output will consist of the called number, the time in minutes the call spent in each of the charge categories, the charging step and the total cost in the format shown below.
输出的每一行要包含拨出的号码,每个话费阶段的分钟数。话费阶段编号以及总费用。并按例如以下格式输出。
Sample Input
输入演示样例
A 183-5724 17 58 18 04
#
Sample Output
输出演示样例
0 10 20 30
123456789012345678901234567890123456789
183-5724 2 4 0 A 0.44
译注:原文中的演示样例输出为一张非常不清晰的图片。上面的数据来自我AC的程序输出,格式与原图全然同样。最上面灰色的两行为表头表示字符的位置,仅仅作演示样例參照,你的程序不要输出该表头。
红色的数字表示以下一列数据须要对齐的位置(在以下一列的左側为左对齐。在右側为右对齐)。
这题一開始想的很复杂,这题有两个注意点,一是要可以处理跨凌晨0点的问题。二是假设開始时间和结束时间相等的话,那么算通话一天。!
。(就是由于这一点,我一直没AC,f**k)
我的代码例如以下:
#include<iostream>
#include<stdio.h>
typedef struct price{
char step;
double a;
double b;
double c;
}price;
price s[5]={
{'A',0.10,0.06,0.02 },
{'B',0.25,0.15,0.05},
{'C',0.53,0.33,0.13},
{'D',0.87,0.47,0.17},
{'E',1.44,0.80,0.30}};
char phone_number[8];
char tt;
int sh,sm,eh,em;
int startindex;
int endindex;
int a,b,c;
inline double getprice(int i,int index)
{
//printf(" %d\n",i);
if(i<=480){c++;return s[index].c;}
if(480<i&&i<=1080){a++;return s[index].a;}
if(1080<i&&i<=1320){b++;return s[index].b;}
if(i>1320){c++;return s[index].c;}
}
int main(int argc, char *argv[])
{
//freopen("1.in","r",stdin);
scanf("%c",&tt);
while(tt!='#'){
char cc=tt;
scanf("%s",phone_number);
scanf("%d %d %d %d",&sh,&sm,&eh,&em);
a=b=c=0;
int index=0;
for(;index<5;++index)
{
if(s[index].step==cc)
break;
}
int E=eh*60+em;
int S=sh*60+sm;
double sum=0;
if(S<E){
for(int i=S+1;i<=E;++i)
{
sum+=getprice(i,index);
}
}
else if(S==E)
{
for(int i=S+1;i<=1440;++i)
sum+=getprice(i,index);
for(int i=1;i<=E;++i)
sum+=getprice(i,index);
}
else
{
for(int i=S+1;i<=1440;++i)
sum+=getprice(i,index);
for(int i=1;i<=E;++i)
sum+=getprice(i,index);
}
printf("%10s%6d%6d%6d%3c%8.2lf\n", phone_number, a, b,c, cc, sum);
scanf("\n%c",&tt);
}
return 0;
}
UVa145 Gondwanaland Telecom的更多相关文章
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- 详解Telecom
学习目标: 掌握Telecom入口和分析方法 总结和演进Telecom交互模型 掌握Listener消息回调机制 学习CallsManager 为什么选择Telecom分析? 这是由于在Android ...
- Android N开发 你需要知道的一切
title: Android N开发 你需要知道的一切 tags: Android N,Android7.0,Android --- 转载请注明出处:http://www.cnblogs.com/yi ...
- 数百个 HTML5 例子学习 HT 图形组件 – 拓扑图篇
HT 是啥:Everything you need to create cutting-edge 2D and 3D visualization. 这口号是当年心目中的产品方向,接着就朝这个方向慢慢打 ...
- 网络切片在5G中的应用
SDNLAB君 • 16-11-25 •1509 人围观 5G和网络切片 当5G被广泛提及的时候,网络切片是其中讨论最多的技术.像KT.SK Telecom.China Mobile.DT.KDDI. ...
- 如何在ARM中创建Express Route
很早之前就想试试Azure的express route,但是一直没有找到合适的机会,正好有个客户需要上express route,所以最近先自己研究研究,防止在做poc的时候耗费更多时间,本次场景我们 ...
- iOS开发中手机号码和价格金额有效性判断及特殊字符的限制
在实际开发过程中,经常会遇到些不能让用户随便地输入手机号码,对输入的手机号码的正确判断:有些输入框只能输入数字,不能输入字母或特殊字符:还有些如价格金额之类的就只能输入数字和小数点且小数点后面保留两位 ...
- GO语言的开源库
Indexes and search engines These sites provide indexes and search engines for Go packages: godoc.org ...
- bench.sh 跑分测速
#!/bin/bash #==============================================================# # Description: bench te ...
随机推荐
- HDU 6186 CS Course【前后缀位运算枚举/线段树】
[前后缀枚举] #include<cstdio> #include<string> #include<cstdlib> #include<cmath> ...
- 树形dp入门(poj 2342 Anniversary party)
题意: 某公司要举办一次晚会,但是为了使得晚会的气氛更加活跃,每个参加晚会的人都不希望在晚会中见到他的直接上司,现在已知每个人的活跃指数和上司关系(当然不可能存在环),求邀请哪些人(多少人)来能使得晚 ...
- hdu 1251 (Trie水题)
统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others)Total Submi ...
- hdu 5963 朋友(2016ccpc 合肥站 C题)
朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submissi ...
- AGC 012 B - Splatter Painting
题面在这里! (显然首先想到反着做比较简单,每个点取第一次被覆盖到的颜色) 发现d非常小,那么是否可以暴力覆盖呢??? 考虑一个稠密图..暴力肯定就gg了啊... 不过我们可以对每一个点 i 记一个m ...
- [UOJ218]火车管理
建一棵答案线段树存栈顶值,两棵可持久化线段树分别存栈顶值和栈顶元素入栈时间 询问就直接在答案线段树上查,弹栈就用入栈时间在对应版本的可持久化线段树上查询即可,修改就是可持久化线段树的区间覆盖 以前一直 ...
- 【推导】【找规律】【二分】hdu6154 CaoHaha's staff
题意:网格图.给你一个格点多边形的面积,问你最少用多少条边(可以是单位线段或单位对角线),围出这么大的图形. 如果我们得到了用n条边围出的图形的最大面积f(n),那么二分一下就是答案. n为偶数时,显 ...
- 【找规律】【DFS】Gym - 101174H - Pascal's Hyper-Pyramids
二维下,如果把杨辉三角按照题目里要求的那样摆放,容易发现,第i行第j列的数(从0开始标号)是C(i+j,i)*C(j,j). 高维下也有类似规律,比如三维下,最后一层的数其实是C(i+j+k,i)*C ...
- 实验四实验报告————Android基础开发
实验四实验报告----Android基础开发 任务一 关于R类 关于apk文件 实验成果 任务二 活动声明周期 实验成果 任务三 关于PendingIntent类 实验成果 任务四 关于布局 实验成果 ...
- (转)Linux下数据段的区别(数据段、代码段、堆栈段、BSS段)
进程(执行的程序)会占用一定数量的内存,它或是用来存放从磁盘载入的程序代码,或是存放取自用户输入的数据等等.不过进程对这些内存的管理方式因内存用途 不一而不尽相同,有些内存是事先静态分配和统一回收的, ...