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

  1. Uva 10339 - Watching Watches【数论,暴力】

    题目链接:10339 - Watching Watches 题意:两个时钟,一个每天慢a秒,一个每天慢b秒,问两钟重新相遇的时刻 1圈有12 * 60 * 60秒,然后1圈 / abs(a - b), ...

  2. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  3. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  4. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  5. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

  6. UVA计数方法练习[3]

    UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...

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

  8. UVA - 1625 Color Length[序列DP 代价计算技巧]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

  9. UVA - 10375 Choose and divide[唯一分解定理]

    UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

随机推荐

  1. SkylineGlobe Android 开发 面积计算示例代码

    SkylineGlobe Android 开发 面积计算示例代码: 如果之前熟悉SkylineGlobe桌面端的二次开发,看这些代码应该不难理解. package com.skyline.terrae ...

  2. char.IsLetter的使用

    先看一下下面的代码,大家会觉得控制台输出什么? 输出:Chiantxt  .对吗? 因为你看到char.IsLetter这个方法的文字的注释是这样写的: 但实际上输出的结果是这样的: ??? 怎么还输 ...

  3. odooERP系统(框架)总结

    1:Odoo 是一个现代化的商业应用套件,使用 AGPL 许可证,并具有客户关系管理(CRM),人力资源,销售,采购,会计,制造,仓库管理,项目管理,以及众多社区模块. 2:它是基于一个模块化,可扩展 ...

  4. Intellij实用技巧

    快捷键 Tradition 快捷键 介绍 Ctrl + Z 撤销 Ctrl + Shift + Z 取消撤销 Ctrl + X 剪切 Ctrl + C 复制 Ctrl + S 保存 Tab 缩进 Sh ...

  5. Missing value auth-url required for auth plugin password

    在控制台输入openstack相关命令时提示如下: openstack user list Missing value auth-url required for auth plugin passwo ...

  6. java 基础02 打包package

  7. 使用Pandas_UDF快速改造Pandas代码

    1. Pandas_UDF介绍 PySpark和Pandas之间改进性能和互操作性的其核心思想是将Apache Arrow作为序列化格式,以减少PySpark和Pandas之间的开销. Pandas_ ...

  8. R实战 第十一篇:处理缺失值

    在真实的世界中,缺失数据是经常出现的,并可能对分析的结果造成影响.在R中,经常使用VIM(Visualization and Imputation of Missing values)包来对缺失值进行 ...

  9. 《Linux内核分析》第六周笔记 进程的描述和进程的创建

    进程的描述和进程的创建 一.进程的描述 1.进程描述符task_struct数据结构(一) 操作系统的三大功能:进程管理(核心).内存管理.文件系统. 进程控制块PCB——task_struct(进程 ...

  10. keras-VGG16 猫狗分类器

    keras 原理: keras系列︱图像多分类训练与利用bottleneck features进行微调(三)https://blog.csdn.net/sinat_26917383/article/d ...