题目: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. C#的is和as操作符来进行强制类型转换&&值类型的拆箱、装箱

    if(o is Employee) { Employee e=(Employee)o; //在if语句剩余的部分中使用e; } Employee e=o as Employee; if(e!=null ...

  2. (转) C#如何使用异步编程

    怎么使用异步,就是用委托进行处理,如果委托对象在调用列表中只有一个方法,它就可以异步执行这个方法.委托类有两个方法,叫做BeginInvoke和EndInvoke,它们是用来异步执行使用. 异步有三种 ...

  3. ios 使用block中使用self可能产生的循环引用

    在block中调用 self,那么就会引起循环引用问题,那么这是为什么呢? 为什么self会对block进行强引用呢???? 这里推荐一篇关于block的专业文章,http://blog.csdn.n ...

  4. socket端口重复占用问题

    1.一个服务端进程在主动释放端口后(调用close)端口状态为TIME_WAIT,这时再去监听同样的端口,不论是否设置SO_REUSEADDR,都能监听成功,也能接收到客户端的连接,但是无法收到数据. ...

  5. codeforces 556B. Case of Fake Numbers 解题报告

    题目链接:http://codeforces.com/problemset/problem/556/B 题目意思:给出 n 个齿轮,每个齿轮有 n 个 teeth,逆时针排列,编号为0 ~ n-1.每 ...

  6. spfa(模板)

    spfa作为图论中的常用算法,深受各类出题人和各位OIer的喜爱: so,为了给大众创造福利,宝宝在此奉上spfa大发的思路和模板:以感谢社会, 感谢CCF,感谢CCTV, 感谢我的老师,感谢同学们, ...

  7. 最详细的 Android Toolbar 开发实践总结

    http://www.codeceo.com/article/android-toolbar-develop.html     参考此链接!

  8. 【leetcode】House Robber & House Robber II(middle)

    You are a professional robber planning to rob houses along a street. Each house has a certain amount ...

  9. UIScrollView控件实现图片缩放功能

    转发自:http://www.cnblogs.com/wendingding/p/3754268.html 一.缩放 1.简单说明: 有些时候,我们可能要对某些内容进行手势缩放,如下图所示 UIScr ...

  10. php生成对象的研究

    <?php abstract class E{ protected $name; function __construct($name){ $this->name = $name; } a ...