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) ...
随机推荐
- cell上添加倒计时,以及时差问题的解决
原址 http://www.cnblogs.com/zhangmaliang/p/5102518.html 最近项目中用到了tableView的多个cell倒计时系统问题,本觉得很简单的一个事,一做发 ...
- 深入JS原型与原型链
要了解原型和原型链,首先要理解普通对象和函数对象. 一.普通对象和函数对象的区别 在Javascript的世界里,全都是对象,而对象之间也是存在区别,我们首先区分一下普通对象和函数对象,如下代码: f ...
- Docker(二):Docker镜像使用
1.Docker Image介绍 简单来说,Docker Image是用来启动容器的只读模板. Docker Image被划分了三个部分:Remote-dockerhub.com/namespace/ ...
- lesson - 8 Linux文档的压缩和打包
内容概要:1. gzip工具语法: gzip [-d#] filename 其中#为1-9的数字,默认压缩级别为6 只能压缩文件gzip filename 生成filename.gz 源文件消失解压 ...
- 7.nginx伪静态规则
网上收集的一些常用的,要用的时候就仿照一下,或直接拿来用. WordPress伪静态规则 location / { index index.html index.php; if (-f $reques ...
- ADB 安卓开发配置环境
下载完后将名称中含有adb的文件,和fastboot.exe复制到 c:/windows/system32目录 或c:/windows/system64目录(看自己电脑系统配置 如电脑64操作系统就写 ...
- Error in library(DESeq2) : 不存在叫‘DESeq2’这个名字的程辑包
Error in read.dcf(file.path(pkgname, "DESCRIPTION"), c("Package", "Type&quo ...
- css3毛玻璃模糊效果
CSS3 blur滤镜实现如下测试代码: .blur { -webkit-filter: blur(10px); /* Chrome, Opera */ -moz-filter: blur(10px) ...
- bash脚本之数组学习
在bash中可使用索引数组和关联数组,bash在4.0版本之后才添加了对关联数组的支持 一.索引数组 1.定义索引数组 # 方式1 array_value=(1 2 3 4 5 6)或者array_v ...
- Flask 框架 简介
一.Flask介绍 Flask是一个基于Werkzeug,Jinja 2 轻量级的web开发框架, 使用Python开发, 上手简单. 二.安装Flask 三.第一个Flask程序 1.编写app.p ...