PAT A 1016. Phone Bills (25)【模拟】
题目:https://www.patest.cn/contests/pat-a-practise/1016
思路:用结构体存储,按照名字和日期排序,然后先判断是否有效,然后输出,时间加减直接暴力即可
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<string.h>
using namespace std;
typedef long long LL;
const int INF = 0x7FFFFFFF;
const int maxn = 1e3 + ;
double f[maxn];
int n, x;
char ss[maxn]; struct point
{
string s;
int a, b, c, d, f;
void read()
{
cin >> s;
scanf("%d:%d:%d:%d", &a, &b, &c, &d);
scanf("%s", ss);
if (ss[] == 'n')f = ; else f = ;
}
bool operator<(const point &x)const
{
return s == x.s ? a == x.a ? b == x.b ? c == x.c ? d < x.d : c < x.c : b < x.b : a < x.a : s < x.s;
}
bool operator==(const point &x)const
{
return b == x.b&&c == x.c&&d == x.d;
}
}a[maxn]; double putout(point x, point y)
{
double ans = ;
int cnt = ;
point u = x;
while (true)
{
ans += f[u.c]; u.d += ;
u.c += u.d / ; u.d %= ;
u.b += u.c / ; u.c %= ;
cnt++; if (u == y) break;
}
printf("%02d:%02d:%02d %02d:%02d:%02d %d $%.2lf\n", x.b, x.c, x.d, y.b, y.c, y.d, cnt, ans);
return ans;
} int main()
{
for (int i = ; i < ; i++)scanf("%d", &x), f[i] = x / 100.0;
scanf("%d", &n);
for (int i = ; i < n; i++)a[i].read();
sort(a, a + n);
for (int i = , j; i < n; i = j)
{
int flag = , y = a[i].f;
for (j = i + ; a[j].s == a[i].s; j++)
{
if (!y&&a[j].f){ flag = ; break; }
else y = a[j].f;
}
if (flag)
{
cout << a[i].s;
printf(" %02d\n", a[i].a);
point x = a[i];
double ans = ;
for (j = i + ; a[j].s == a[i].s; j++)
{
if (!x.f&&a[j].f)ans += putout(x, a[j]);
x = a[j];
}
printf("Total amount: $%.2lf\n", ans);
}
}
return ;
}
PAT A 1016. Phone Bills (25)【模拟】的更多相关文章
- PAT 甲级 1016 Phone Bills (25 分) (结构体排序,模拟题,巧妙算时间,坑点太多,debug了好久)
1016 Phone Bills (25 分) A long-distance telephone company charges its customers by the following r ...
- PAT甲题题解-1016. Phone Bills (25)-模拟、排序
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789229.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- 1016. Phone Bills (25)——PAT (Advanced Level) Practise
题目信息: 1016. Phone Bills (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A l ...
- PAT甲级1016. Phone Bills
PAT甲级1016. Phone Bills 题意: 长途电话公司按以下规定向客户收取费用: 长途电话费用每分钟一定数量,具体取决于通话时间.当客户开始连接长途电话时,将记录时间,并且客户挂断电话时也 ...
- PAT (Advanced Level) 1016. Phone Bills (25)
简单模拟题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...
- 【PAT甲级】1016 Phone Bills (25 分)(结构体排序)
题意: 输入24个正整数代表从0到23每个小时通话一分钟花费的美分.输入一个正整数N(<=1000),然后输入N组字符串,每个字符串包含客户的名字和通话的时刻以及打出或者挂断的状态. 按照字典序 ...
- 1016 Phone Bills (25)(25 point(s))
problem A long-distance telephone company charges its customers by the following rules: Making a lon ...
- 1016. Phone Bills (25) -vector排序(sort函数)
题目如下: A long-distance telephone company charges its customers by the following rules: Making a long- ...
- 1016 Phone Bills (25 分)
A long-distance telephone company charges its customers by the following rules: Making a long-distan ...
随机推荐
- Struts2学习笔记《三》
Struts2的工作原理图: struts的用法:
- 用C语言把双向链表中的两个结点交换位置,考虑各种边界问题。
用C语言把双向链表中的两个结点交换位置,考虑各种边界问题. [参考] http://blog.csdn.net/silangquan/article/details/18051675
- angular.js初探
2015年7月27日 22:26:35 星期一 用在我论坛里的小栗子: 先列出来一级回帖, 点击帖子前边的"查看回复"按钮无刷新的去请求该帖子的所有回复 首先要引用js文件, 我这 ...
- ACM/ICPC 之 Prim范例(ZOJ1586-POJ1789(ZOJ2158))
两道Prim解法范例题型,简单的裸Prim,且两题相较以边为重心的Kruskal解法而言更适合以点为重心扩展的Prim解法. ZOJ1586-QS Network 题意:见Code 题解:直接的MST ...
- percona-toolkit 之 【pt-summary】、【pt-mysql-summary】、【pt-config-diff】、【pt-variable-advisor】说明
摘要: 通过下面的这些命令在接触到新的数据库服务器的时候能更好更快的了解服务器和数据库的状况. 1:pt-summary:查看系统摘要报告 执行: pt-summary 打印出来的信息包括:CPU.内 ...
- python中的编码问题:以ascii和unicode为主线
1.unicode.gbk.gb2312.utf-8的关系 http://www.pythonclub.org/python-basic/encode-detail 这篇文章写的比较好,utf-8 ...
- 【leetcode】Binary Tree Right Side View(middle)
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nod ...
- ServletConfig与ServletContext
ServletConfig与ServletContext对象详解 一.ServletConfig对象 在Servlet的配置文件中,可以使用一个或多个<init-param>标签为s ...
- CUDA中并行规约(Parallel Reduction)的优化
转自: http://hackecho.com/2013/04/cuda-parallel-reduction/ Parallel Reduction是NVIDIA-CUDA自带的例子,也几乎是所有C ...
- 在R语言中无法设置CRAN镜像问题
很大的可能是因为使用的浏览器不是IE浏览器的问题,因为CRAN的镜像需要用IE浏览器来打开. 只需要按照下面设置即可: 1.打开IE-->设置-->Internet选项-->高级 2 ...