题目: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)【模拟】的更多相关文章

  1. PAT 甲级 1016 Phone Bills (25 分) (结构体排序,模拟题,巧妙算时间,坑点太多,debug了好久)

    1016 Phone Bills (25 分)   A long-distance telephone company charges its customers by the following r ...

  2. PAT甲题题解-1016. Phone Bills (25)-模拟、排序

    博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6789229.html特别不喜欢那些随便转载别人的原创文章又不给 ...

  3. 1016. Phone Bills (25)——PAT (Advanced Level) Practise

    题目信息: 1016. Phone Bills (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A l ...

  4. PAT甲级1016. Phone Bills

    PAT甲级1016. Phone Bills 题意: 长途电话公司按以下规定向客户收取费用: 长途电话费用每分钟一定数量,具体取决于通话时间.当客户开始连接长途电话时,将记录时间,并且客户挂断电话时也 ...

  5. PAT (Advanced Level) 1016. Phone Bills (25)

    简单模拟题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm& ...

  6. 【PAT甲级】1016 Phone Bills (25 分)(结构体排序)

    题意: 输入24个正整数代表从0到23每个小时通话一分钟花费的美分.输入一个正整数N(<=1000),然后输入N组字符串,每个字符串包含客户的名字和通话的时刻以及打出或者挂断的状态. 按照字典序 ...

  7. 1016 Phone Bills (25)(25 point(s))

    problem A long-distance telephone company charges its customers by the following rules: Making a lon ...

  8. 1016. Phone Bills (25) -vector排序(sort函数)

    题目如下: A long-distance telephone company charges its customers by the following rules: Making a long- ...

  9. 1016 Phone Bills (25 分)

    A long-distance telephone company charges its customers by the following rules: Making a long-distan ...

随机推荐

  1. 【Other】Ubuntu 14.04 pptp 客户端连接配置

    sudo apt-get install pptp-linux binutils modprobe ppp_mppe sudo pptpsetup --create testvpn --server ...

  2. 【GoLang】GoLang 的流程与函数

    003.GO流程与函数 1 概述 1.1 Go中流程控制分三大类:条件判断,循环控制和无条件跳转 2 流程 2.1 if 2.1.1 if条件判断语句中不需要括号 2.1.2 条件判断语句里面允许声明 ...

  3. Git引用

    原文: http://gitbook.liuhui998.com/7_3.html git中,分支(branch), 远程跟踪分支(remote-tracking branch)以及标签(tag)都是 ...

  4. 7.31 签到,js 全局预处理笔记

    js 解析与执行过程: 一.全局:  1.预处理阶段 : 1.LexicalEnviroment === window {1.预处理 var   |   2.function xxx //预处理申明的 ...

  5. 使用SharePoint 2010 母版页

    SharePoint 2010母版页所用的还是ASP.NET 2.0中的技术.通过该功能,实现了页面框架布局与实际内容的分离.虽然在本质上自定义母版页的过程和以前版本的SharePoint大致相同,但 ...

  6. Qt qss 使用

    1.在资源文件建立一个qss文件.如blue.qss 2. 调用 #include "mainwindow.h" #include <QApplication> #in ...

  7. selenium 配合sikuli script操作高德地图

    会不会使用工具,是一般QA和高级QA的区别 ---To be crazy Java就是好,开源框架遍地都是,各种niubility的jar包,各种神器,真是不亦乐乎. 今天研究一下基于图片识别作为对象 ...

  8. 构建web应用示例

    1.1 请求方法的判断 var http = require('http'); var server = http.createServer(function(request,response){ s ...

  9. 数据结构-链表逆置(c++模板类实现)

    链表结点类模板定义: template <class T> class SingleList; template <class T> class Node { private: ...

  10. spring mvc 重定向问题

    (1)我在后台一个controller跳转到另一个controller,为什么有这种需求呢,是这样的.我有一个列表页面,然后我会进行新增操作,新增在后台完成之后我要跳转到列表页面,不需要传递参数,列表 ...