2017ecjtu-summer training #1 UVA 10399
It has been said that a watch that is stopped keeps better time than one that loses 1 second per day.
The one that is stopped reads the correct time twice a day while the one that loses 1 second per day is correct only once every 43,200 days.
This maxim applies to old fashioned 12-hour analog watches, whose hands move continuously (most digital watches would display nothing at all if stopped).
Given two such analog watches, both synchronized to midnight, that keep time at a constant rate but run slow by k and m seconds per day respectively, what time will the watches show when next they have exactly the same time?
Input
Input consists of a number of lines, each with two distinct non-negative integers k and m between 0 and 256, indicating the number of seconds per day that each watch loses.
Output
For each line of input, print k, m, and the time displayed on each watch, rounded to the nearest minute. Valid times range from 01:00 to 12:59.
Sample Input
1 2
0 7
Sample Output
1 2 12:00
0 7 10:17
题意 两个表一个表一天慢k秒,另一个表一天慢m秒,问下一次相同的时间是多少
表的一圈是43200秒,一天是86400秒
追及问题 经过43200/m-k天再次时间一样
此时 表走了( 43200/m-k )*( 86400-k )秒
AC代码
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <queue>
#include <vector>
#include <algorithm>
#define maxn 100010
using namespace std;
typedef long long ll;
int main()
{
int k,m;
int min,h;
while(scanf("%d%d",&k,&m)!=EOF)
{
int a=abs(m-k);
ll s=(ll)(43200.0/a*(86400.0-k));
s%=; //这些天转了s/43200圈后剩余的秒数
int min=s/; //求出分钟数
s%=; //rounded to the nearest minute
if(s>=)
min++;
int h=min/; //求出小时数
min%=; // 分的时间
h%=; // 没有0点换成12点
if(h==)
h=;
printf("%d %d %02d:%02d\n", k, m, h, min);//格式输出
}
}
2017ecjtu-summer training #1 UVA 10399的更多相关文章
- 2017ecjtu-summer training #1 UVA 12050
A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, th ...
- 2018 Spring Single Training B (uva 572,HihoCoder 1632,POJ 2387,POJ 2236,UVA 10054,HDU 2141)
这场比赛可以说是灰常的水了,涨信心场?? 今下午义务劳动,去拿着锄头发了将近一小时呆,发现自己实在是干不了什么,就跑到实验室打比赛了~ 之前的比赛补题补了这么久连一场完整的都没补完,结果这场比完后一小 ...
- Mango DS Training #48 ---线段树2 解题手记
Training address: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=38966#overview A.Count Color ...
- Tri_integral Summer Training 9 总结
比赛链接 A B C D H I J K 多灾多难的 Summer Training 9,前一天挂了一场比赛,结果题一半不能做,于是打了一个小时就放弃了.之后的两场Summer Training 9一 ...
- The Summer Training Summary-- the first
The Summer Training Summary-- the first A - vector的使用 UVa 101 关于vector 的几个注意点 vector p p.push_back() ...
- hdu 4946 2014 Multi-University Training Contest 8
Area of Mushroom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
- 2016 Multi-University Training Contests
2016 Multi-University Training Contest 1 2016 Multi-University Training Contest 2 2016 Multi-Univers ...
- 2016 Multi-University Training Contest 2 D. Differencia
Differencia Time Limit: 10000/10000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tot ...
- 2016 Multi-University Training Contest 1 G. Rigid Frameworks
Rigid Frameworks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...
随机推荐
- [Find the last digit when factorial of A divides factorial of B]
Given two numbers A and B. The task is to compute the last digit of the resulting F, where F= B! / A ...
- window下nginx的常用命令
window nginx 启动 常用命令 2016-05-04 11:11 214人阅读 评论(0) 收藏 举报 分类: nginx(5) 版权声明:本文为博主原创文章,未经博主允许不得转载. 启动 ...
- Linux(CentOS6.5)下编译安装MySQL Community Server 5.7.12
组件 官方网站 直接下载地址 备注 mysql http://dev.mysql.com/downloads/mysql/ http://mirrors.sohu.com/mysql/MySQL- ...
- Eclipse配置tomcat程序发布到哪里去了?
今天帮同事调一个问题,明明可以main函数执行的,他非要固执的使用tomcat执行,依他.但是发布到tomcat之后我想去看看发布后的目录,所以就打开了tomcat中的webapps目录,可是并没有发 ...
- [编织消息框架][消息服务]rmi
RMI(即Remote Method Invoke 远程方法调用) 远程对象: 用于远程客户端调用 必需继承java.rmi.Remote,每个调用方法必须添加java.rmi.RemoteExcep ...
- IDA Pro反编译代码类型转换参考
/* This file contains definitions used by the Hex-Rays decompiler output. It has type definitions an ...
- zabbix web监控模板
问题关键:宏变量 {HOST.NAME} 配置 我直接在 Linux OS这个模板中添加的,都随意: 效果 加个报警 以上.
- jsp 之 解决mysql不是内部或外部命令问题
安装Mysql后,当我们在cmd中敲入mysql时会出现'Mysql'不是内部或外部命令,也不是可运行的程序或其处理文件. 打开我的电脑在我的电脑右键中选择属性,然后单击选择高级系统设置. 在系统属性 ...
- [Spark内核] 第38课:BlockManager架构原理、运行流程图和源码解密
本课主题 BlockManager 运行實例 BlockManager 原理流程图 BlockManager 源码解析 引言 BlockManager 是管理整个Spark运行时的数据读写的,当然也包 ...
- linux无密码连接
先确保所有主机的防火墙处于关闭状态. 在主机A上执行如下: 1. $cd ~/.ssh 2. $ssh-keygen -t rsa -----然后一直按回车键,就会按照默认的选项将生成的密钥保存在. ...