Avoiding a disaster

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 211    Accepted Submission(s): 101

Problem Description
Percy
likes to be punctual. So much so that he always keeps three watches
with him, so that he can be sure exactly what the time is. However,
Percy's having a bad day. He found out that one of his watches was
giving the wrong time. What's worse, when he went to correct the watch,
he corrected the wrong one! That is, one watch was running x minutes
behind (where x <= 480) and he wound one of the other watches x
minutes forward. He now has three watches reading three different times,
and hence is in serious danger of being tardy. Can you help Percy by
writing a program that takes in the three times displayed on the watches
and returns the correct time?
 
Input
The input begins with an integer T indicating the number of cases that follow (0 < T
<
100). Each of the following T lines contains one test case, made up of
three readings, separated by single space characters: H1:M1 H2:M2 H3:M3
In each reading H1,H2,H3 represent the hours displayed (0 < H1,H2,H3
< 13), and M1,M2,M3 represent the minutes displayed (0 <= M1,M2,M3
< 60).
If the number of minutes is less than 10, a leading 0 is added.
 
Output
For each test case, one line should be produced, formatted exactly as follows: "The
correct time is Hi:Mi". If the number of minutes is less than 10, a leading 0 should be
added.
If the number of hours is less than 10, a leading 0 should NOT be
added. If it is impossible to tell the time from the three readings,
print the string: "Look at the sun".
 
Sample Input
3
5:00 12:00 10:00
11:59 12:30 1:01
12:00 4:00 8:00
 
Sample Output
The correct time is 5:00
The correct time is 12:30
Look at the sun
 
Source
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  4178 4186 4180 4181 4182 
 
 
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
char c1,c2,c3;
int h1,h2,h3;
char m11,m12,m21,m22,m31,m32;
scanf("%d%c%c%c",&h1,&c1,&m11,&m12);
getchar();
scanf("%d%c%c%c",&h2,&c2,&m21,&m22);
getchar();
scanf("%d%c%c%c",&h3,&c3,&m31,&m32);
int min1=,min2=,min3=;
min1=h1*+m11*+m12;
min2=h2*+m21*+m22;
min3=h3*+m31*+m32;
int p1=,p2=,p3=;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1-=*;
min2+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min2-=*;
min3+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1+=*;
min2+=*;
min3-=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min2-=*;
min3+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1-=*;
min2+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
min1+=*;
if(min1+min2==*min3&&fabs(min1-min3)<=)
p3++;
else if(min1+min3==*min2&&fabs(min1-min2)<=)
p2++;
else if(min3+min2==*min1&&fabs(min3-min1)<=)
p1++;
if(p1>&&p2>||p1>&&p3>||p2>&&p3>)
printf("Look at the sun\n");
else if(p1>)
{
printf("The correct time is %d:%c%c\n",h1,m11,m12);
}
else if(p2>)
{
printf("The correct time is %d:%c%c\n",h2,m21,m22);
}
else if(p3>)
{
printf("The correct time is %d:%c%c\n",h3,m31,m32);
}
}
return ;
}

HDU 4177 模拟时间问题的更多相关文章

  1. hdu 2079 选课时间

    hdu 2079 选课时间 题意:选的学分总和为n,并且学分为a的课有b种,总共有K(1<=k<=8)种学分不同的课,并且要选的学分最多为40:问选课方案有多少种?(学分相同的课即认为相同 ...

  2. hdu 4891 模拟水题

    http://acm.hdu.edu.cn/showproblem.php?pid=4891 给出一个文本,问说有多少种理解方式. 1. $$中间的,(s1+1) * (s2+1) * ...*(sn ...

  3. hdu 5012 模拟+bfs

    http://acm.hdu.edu.cn/showproblem.php?pid=5012 模拟出骰子四种反转方式,bfs,最多不会走超过6步 #include <cstdio> #in ...

  4. HDU 2079 选课时间(普通型 数量有限 母函数)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2079 选课时间(题目已修改,注意读题) Time Limit:1000MS     Memory Li ...

  5. hdu 4669 模拟

    思路: 主要就是模拟这些操作,用链表果断超时.改用堆栈模拟就过了 #include<map> #include<set> #include<stack> #incl ...

  6. hdu 2079 选课时间(题目已修改,注意读题)

    http://acm.hdu.edu.cn/showproblem.php?pid=2079 背包 #include <cstdio> #include <cstring> # ...

  7. 2013杭州网络赛C题HDU 4640(模拟)

    The Donkey of Gui Zhou Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  8. HDU 2079-课程时间(生成函数)

    课程时间(标题已被修改,注意阅读题) Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  9. HDU/5499/模拟

    题目链接 模拟题,直接看代码. £:分数的计算方法,要用double; #include <set> #include <map> #include <cmath> ...

随机推荐

  1. Python核心编程——多线程threading和队列

    线程与进程类似不过他们是在同一个进程下执行的,并共享相同的上下文.可以将他们认为是在一个主进程或“主线程”中运行的迷你进程. 线程包括开始.执行顺序和结束三部分.它有一个指令指针,用于记录当前运行的上 ...

  2. BZOJ3932(主席树上二分+差分

    按时间作为主席树的版本,每个版本的主席树都是一个权值线段树. 差分消去时间影响 对于当前时间版本的主席树查询前K大即可. 树上二分时结束后切记判定l==r的状态(易错 l==r叶子节点可能存在多个值( ...

  3. python读取图像

    from PIL import Imageimg = Image.open('/Users/NaCl/Desktop/test.png')img.show()

  4. java面向对象思想2

    1.主函数是一类特殊的函数,作为程序入口,可被虚拟机调用.主函数格式是固定的.public:函数访问权限最大.static:代表函数随着类的加载已经存在.void:主函数没有具体返回值.main:不是 ...

  5. 当GetWindowText获取不到标题时可以用SendMessage

    GetWindowText所有父窗口标题基本可以获取到, 但是当获取父窗口下的子窗口控件标题文本时有时候就没那么好用了, 这个时候可以通过SendMessage发送消息来获取,也很简单,C/C++代码 ...

  6. shell脚本中case的用法

    shell脚本中case选择语句可以结合read指令实现比较好的交互应答操作,case接收到read指令传入的一个或多个参数,然后case根据参数做选择操作. case的语法如下 case $char ...

  7. IE console报错

    需要注意的是,使用console对象查看对象信息,在IE8浏览器下未打开开发人员工具(F12)的情况下 会报'console'未定义错误. 解决办法:1.打开开发人员调试工具(F12)        ...

  8. Python_深浅拷贝

    深浅拷贝 ‘copy’和'='的区别:copy会开辟一个新的空间,而‘=’不会. 浅copy只会copy第一层,再里边的就进行共享了. 需要记住的是copy之后记住的是内存寻址地址,而浅copy时如果 ...

  9. DDOS与DOS的区别

    0x01 在说之前,先看一些例子吧 还有众所周知的中美黑客大战,新闻我就不说了 0x02 什么是DOS DoS是Denial of Service的简称,即拒绝服务,造成DoS的攻击行为被称为DoS攻 ...

  10. JS进阶篇--JS数组reduce()方法详解及高级技巧

    基本概念 reduce() 方法接收一个函数作为累加器(accumulator),数组中的每个值(从左到右)开始缩减,最终为一个值. reduce 为数组中的每一个元素依次执行回调函数,不包括数组中被 ...