UVa - 10339
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
解题思路:
题意:
有两个表每天分别慢a,b秒,要求当这两个表重合的时候,A钟的时间;
思路:
首先要求两表重合,那么两表相差的时间必为12个小时: 43200/abs(a-b),求出所需的天数;
下一步则要求钟A此时走了多少秒 day*(86400-n); 因为这是表a记录的时间,所以要减去表a一天慢的秒数
最后就是时间的转换了;
实现代码:
#include<cstdio>
#include<cmath>
using namespace std;
#define ll long long
int main()
{
int a,b;
while(scanf("%d%d",&a,&b)!=EOF){
int ans = abs(a-b);
double day = 43200.0/ans;
ll tA = (ll)(day*(-a));
tA = tA%;
int min = tA/;
tA%=;
if(tA >= ) min++;
int hour = min/;
min %= ;
if(hour == )
hour = ;
printf("%d %d %02d:%02d\n", a,b, hour, min );
}
}
UVa - 10339的更多相关文章
- Uva 10339 - Watching Watches【数论,暴力】
题目链接:10339 - Watching Watches 题意:两个时钟,一个每天慢a秒,一个每天慢b秒,问两钟重新相遇的时刻 1圈有12 * 60 * 60秒,然后1圈 / abs(a - b), ...
- uva 1354 Mobile Computing ——yhx
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5
- UVA 10564 Paths through the Hourglass[DP 打印]
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...
- UVA 11404 Palindromic Subsequence[DP LCS 打印]
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...
- UVA&&POJ离散概率与数学期望入门练习[4]
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...
- UVA计数方法练习[3]
UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...
- UVA数学入门训练Round1[6]
UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...
- UVA - 1625 Color Length[序列DP 代价计算技巧]
UVA - 1625 Color Length 白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束 和模拟赛那道环形DP很想,计算这 ...
- UVA - 10375 Choose and divide[唯一分解定理]
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
随机推荐
- C#析构函数 (转载)
一.C#析构函数 1. 析构函数的定义与注意的问题析构函数用于释放被占用的系统资源.析构函数的名字由符号“-”加类名组成.使用析构函数时,应该注意下面的问题: 只能在类中使用析构函数,不能在结构中使用 ...
- SQL Server CTE 递归查询全解(转载)
在TSQL脚本中,也能实现递归查询,SQL Server提供CTE(Common Table Expression),只需要编写少量的代码,就能实现递归查询,本文详细介绍CTE递归调用的特性和使用示例 ...
- eclipse 打包
add directory entries 不勾选, spring 自动扫描之类的扫描不到
- Ubuntu 16.04 下部署Node.js+MySQL微信小程序商城
转载于这篇文章 关于pm2看这篇文章 最近在研究小程序,申请了域名之后,再一次来配置环境,根据作者的步骤基本上完成了网站的架构,但由于环境路径等不同,配置上会有所不同,因此记录下来. 1.更新系统和安 ...
- Java中clone的写法
Cloneable这个接口设计得十分奇葩,不符合正常人的使用习惯,然而用这个接口的人很多也很有必要,所以还是有必要了解一下这套扭曲的机制.以下内容来自于对Effective Java ed 2. it ...
- 【C++】std::是什么?
引例: #include<iostream> int main() { std::cout<<"我喜欢C++";//输出一句话 std::cout<& ...
- LeetCode之Add Two Numbers
Add Two Numbers 方法一: 考虑到有进位的问题,首先想到的思路是: 先分位求总和得到 totalsum,然后再将totalsum按位拆分转成链表: ListNode* addTwoNum ...
- 阿里云Centos搭建jdk环境
当我们开始了自己的开发,那么云服务器是一定少不了的,当然也有很多同学只是在本地做开发研究. 这里记录一下我自己在阿里云上搭建环境的过程. 趁着优惠的时候,我在阿里云上购买了ECS云服务器,并且搭载了C ...
- C. Meme Problem
链接 [http://codeforces.com/contest/1076/problem/C] 题意 a+b=d and a⋅b=d. 计算出a和b 分析 ab=a(d-a)=d aa-ad+d= ...
- “耐撕团队”部署并测试onezero团队记帐本项目
耐撕团队 对onezero团队记帐本项目的部署并测试 测试指标参见下面给出的博客: http://www.ltesting.net/ceshi/ceshijishu/xncs/2014/1030/20 ...