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的更多相关文章

  1. 2017ecjtu-summer training #1 UVA 12050

    A palindrome is a word, number, or phrase that reads the same forwards as backwards. For example, th ...

  2. 2018 Spring Single Training B (uva 572,HihoCoder 1632,POJ 2387,POJ 2236,UVA 10054,HDU 2141)

    这场比赛可以说是灰常的水了,涨信心场?? 今下午义务劳动,去拿着锄头发了将近一小时呆,发现自己实在是干不了什么,就跑到实验室打比赛了~ 之前的比赛补题补了这么久连一场完整的都没补完,结果这场比完后一小 ...

  3. Mango DS Training #48 ---线段树2 解题手记

    Training address: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=38966#overview A.Count Color ...

  4. Tri_integral Summer Training 9 总结

    比赛链接 A B C D H I J K 多灾多难的 Summer Training 9,前一天挂了一场比赛,结果题一半不能做,于是打了一个小时就放弃了.之后的两场Summer Training 9一 ...

  5. The Summer Training Summary-- the first

    The Summer Training Summary-- the first A - vector的使用 UVa 101 关于vector 的几个注意点 vector p p.push_back() ...

  6. 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) ...

  7. 2016 Multi-University Training Contests

    2016 Multi-University Training Contest 1 2016 Multi-University Training Contest 2 2016 Multi-Univers ...

  8. 2016 Multi-University Training Contest 2 D. Differencia

    Differencia Time Limit: 10000/10000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tot ...

  9. 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) ...

随机推荐

  1. 通过SQL创建一个有主键自动递增有默认值不为空有注释的表

    -- create database db_std_mgr_sys; use db_std_mgr_sys; create table student( std_id bigint not null ...

  2. 一个两年java程序猿的2017个人总结

    前言 又到了一年中最后的日子了,相信有不少公司要求员工写年度总结了,我也不例外.不过个人感觉在公司的写个年度总结来说,过于模板化了.其实很多没有必要.总之,本篇的个人总结,是按照个人的想法写的.简而言 ...

  3. bzoj 2753: [SCOI2012]滑雪与时间胶囊

    Description a180285非常喜欢滑雪.他来到一座雪山,这里分布着M条供滑行的轨道和N个轨道之间的交点(同时也是景点),而且每个景点都有一编号i(1<=i<=N)和一高度Hi. ...

  4. Servlet与Jsp的结合使用实现信息管理系统一

    PS:1:先介绍一下什么是Servlet? Servlet(Server Applet)是Java Servlet的简称,称为小服务程序或服务连接器,用Java编写的服务器端程序,主要功能在于交互式地 ...

  5. Java ArrayIndexOutOfBoundsException: Exception Hierarchy

  6. JavaScript的DOM编程--11--插入节点

    插入节点: 1). insertBefore(): 把一个给定节点插入到一个给定元素节点的给定子节点的前面 var reference = element.insertBefore(newNode,t ...

  7. h5拖拽上传图片

    h5实现拖拽上传图片 本文将为大家介绍如何通过js实现拖拽上传图片. 首先我们要禁用调浏览器默认的拖拽事件: window.onload = function(){ //拖离 document.add ...

  8. C# Excel数据导入到数据库

    http://www.jb51.net/article/44743.htm 假如Excel中的数据如下: 数据库建表如下: 其中Id为自增字段: 代码: 复制代码 代码如下: using System ...

  9. java多线程(二)-Runnable和Thread

    Java在顺序性语言的基础上提供了多线程的支持.Java的线程机制是抢占式的.这表示调度机制会周期的中断线程,将上下文切换到另一个线程,从而为每个线程都提供时间片.(与抢占式多线程对应的是 协作式多线 ...

  10. Hyper-V 虚拟网络设置

    目标:搭建一个主机上的网络用来链接主机和虚拟机,并且虚拟机可以通过主机上网. 步骤一:创建一个Internal Network. 步骤二: 创建虚拟机并设置Virtual Switch. 步骤三:将上 ...