uva 10339 - Watching Watches(数论)
来源:互联网 发布:会员卡管理php源码 编辑:程序博客网 时间:2024/05/18 12:03
题目链接:uva 10339 - Watching Watches
题目大意:有两个表,每天都会慢一点时间,给出每天慢得秒数,问说下一次重合的时刻。
解题思路:时刻重合也就是说整整差了一周,一周是12小时,用12小时的秒数除以两个表的相差那就是需要多少天的时间后重合,知道了需要多少天*每一天某个表走的时间(注意要减去少走的时间)即使答案,化成时间的格式即可,注意0时显示成12时。
#include <stdio.h>#include <string.h>#include <math.h>#include <stdlib.h>#include <algorithm>using namespace std;const int R = 12 * 60 * 60;const int D = 24 * 60 * 60;int k, m;int main () {while (scanf("%d%d", &k, &m) == 2) {int d = abs(k - m);if (d == 0) {printf("%d %d 12:00\n", k, m);continue;}double p = R*1.0/d;int t = (int)(p * (D - k)/60.0 + 0.5)%D;int h = t/60;h %= 12;if (h == 0) h = 12;int f = t%60;printf("%d %d %02d:%02d\n", k, m, h, f);}return 0;}
1 0
- uva 10339 - Watching Watches(数论)
- UVA 10339 - Watching Watches(数论+推理)
- UVa 10339 - Watching Watches (数学)
- watches
- watches
- UVa 12715 Watching the Kangaroo(二分)
- UVa 11889 Benefit (数论)
- UVA 10110(数论)
- UVA 571(数论)
- UVA 1529 - Clock(数论)
- UVA 278 - Chess(数论)
- uva 1529 - Clock(数论)
- UVA 10127 - Ones(数论)
- UVA 10090 - Marbles (数论)
- UVA 756 - Biorhythms(数论)
- uva 10127 - Ones(数论)
- UVA 1434 - YAPTCHA(数论)
- uva 1434 - YAPTCHA(数论)
- 认识DOM以及DOM加载过程
- 批量执行sql
- The social media frequency guide: How often should you post?
- 实现对gridview删除行时弹出确认对话框的一种简单方法
- STM32F4-Discovery资料汇总
- uva 10339 - Watching Watches(数论)
- Effective C++——》条款23:宁以non-member、non-frined替换member函数
- nyoj-170-网络的可靠性
- 线程并发集合实现java生成消费模型(ArrayBlockingQueue和ConcurrentMap)
- 爱奇艺视频窗口显示不出来解决办法
- 从键盘读取三个数值并求平均值
- PHP 遇到 2038年的問題該如何解決
- Linux字符界面操作
- 如何通过 USB 设备来安装 CentOS