1016. Phone Bills (25)
来源:互联网 发布:汉密尔顿 知乎 喜剧 编辑:程序博客网 时间:2024/05/20 18:18
这题我感觉略复杂,hold不住,直接上浅蓝大神的代码。
#include<cstdio> #include<string> #include<cstring> #include<vector> #include<iostream> #include<queue> #include<algorithm> using namespace std; typedef long long LL; const int INF = 0x7FFFFFFF; const int maxn = 1e3 + 10; 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[1] == 'n') f = 0; else f = 1; } 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 = 0; int cnt = 0; point u = x; while (true) { ans += f[u.c]; u.d += 1; u.c += u.d / 60; u.d %= 60; u.b += u.c / 24; u.c %= 24; 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 = 0; i < 24; i++) scanf("%d", &x), f[i] = x / 100.0; scanf("%d", &n); for (int i = 0; i < n; i++) a[i].read(); sort(a, a + n); for (int i = 0, j; i < n; i = j) { int flag = 0, y = a[i].f; for (j = i + 1; a[j].s == a[i].s; j++) { if (!y&&a[j].f) { flag = 1; break; } else y = a[j].f; } if (flag) { cout << a[i].s; printf(" %02d\n", a[i].a); point x = a[i]; double ans = 0; for (j = i + 1; 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 0; }
0 0
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 1016. Phone Bills (25)
- 图片处理(防止内存溢出)
- 项目的访问路径问题
- 【C++primer学习日记】2.1基本内置类型
- LeetCode 547 Friend Circles(并查集)
- maven依赖中的scope使用
- 1016. Phone Bills (25)
- 计算机网络2-网络应用
- 主流浏览器内核介绍
- 关于percona-xtrabackup 安装的小纠结
- Netty学习-01-Nio
- UEditor图片居中问题
- 通过数学模型提高效率:求1/1!-1/3!+1/5!-1/7!+...+(-1)^n+1/(2n-1)!
- Java面向对象和方法
- JNOJ 查并集