题目: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. 多节点 devstack 部署

    1, 网络配置 每个节点 /etc/network/interfaces auto eth0 iface eth0 inet static address 192.168.42.11 netmask ...

  2. ios 在storyboard 和 xib中,显示自定义view的预览效果

    发现FSCalendar这个控件能在xib中显示预览效果,是怎么实现的呢?其中涉及的知识又有哪些? 主要就是IBInspectable 和 IB_DESIGNABLE 先看 IBInspectable ...

  3. Linux下常用的硬件信息查看命令

    1.查看CPU型号,这里为了方便查看结合管道符用grep进行了匹配,当然只需要前面的命令也可以,命令如下: cat /proc/cpuinfo | grep "model name" ...

  4. 2.js模式-单例模式

    1. 单例模式 单例模式的核心是确保只有一个实例,并提供全局访问. function xx(name){}; Singleton.getInstance = (function(){ var inst ...

  5. 16~25.spring+hibernate简单实例 .连接数据库并进行增删改查

    1.概念 Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,它将POJO与数据库表建立映射关系,是一个全自动的orm框架,hibernate可以自动生成SQ ...

  6. HDU 4949 Light(插头dp、位运算)

    比赛的时候没看题,赛后看题觉得比赛看到应该可以敲的,敲了之后发现还真就会卡题.. 因为写完之后,无限TLE... 直到后来用位运算代替了我插头dp常用的decode.encode.shift三个函数以 ...

  7. MST:Agri-Net(POJ 1258)

     Agri-Net 题目大意:农夫有一片农场,现在他要把这些田地用管子连起来,田地之间有一定距离,铺设每一段管子的长度与这些田地与田地距离是一样的,问你最小的铺设方案. 这一题很裸,Kruskal算法 ...

  8. 【python】pymongo查找某一时间段的数据

    python中实现: 下面代码就是查找2016-09-26 00:00:00 ~ 2016-09-27 00:00:00 时间段的数据 from datetime import datetimefor ...

  9. python eval和literal_eval

    eval是python中一个相当智能的函数,把参数当成表达式,进行最大限度的解析, 比如: a = "[[1,2], [3,4], [5,6], [7,8], [9,0]]" b ...

  10. hosts文件修改之后立刻刷新

    最近因为项目的需要,总是修改hosts文件,每次修改之后都要重启浏览器,总结下刷新的方式 window下,hosts文件位置:C:\windows\system32\drivers\etc\hosts ...