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_62_装饰器5

    import time def timer(func): #timer(test1) func=test1 def deco(*args,**kwargs): start_time=time.time ...

  2. 18课 Vue第一节

    Q1: url-loader必须搭载file-loader?Q2: 图片的打包问题,如果直接写在img标签里用src引用图片,该如何打包?Q3: 如何根据不同的页面html模板打包与之对应的css/j ...

  3. Python实现购物小程序

    一.需求 1.登录 { ‘xxx1’:{'passwd':'123','role':1,'moeny':10000,"carts":['mac']}, 'xxx1':{'passw ...

  4. AngularJs学习笔记-组件生命周期

    组件生命周期 (1)组件生命周期钩子 constructor:组件创建时被创建 ngOnChanges: 父组件修改或初始化子组件的输入属性时被调用,如果子组件没有输入属性,则永远不会被调用,它的首次 ...

  5. CUDA常见问题与解答

    源 1.在SDK自带的例子程序中,发现SRC文件珜下有.cpp文件和.cu文件.这两种文件的关系和各自的作用是什么呀? 答:SDK自带例子中的.cpp文件主要是一些CPU端处理,或者是使用CPU计算对 ...

  6. 谷歌SwitchySharp && SwitchyOmega插件

    http://pan.baidu.com/s/1jOwgu 谷歌SwitchySharp插件 http://pan.baidu.com/s/1mgl7e2k SwitchySharp的升级版Switc ...

  7. Oracle Hint 之 Parallel

    强制启用oralce的多线程处理功能. 并行查询允许将一个sql select 语句划分为多个较小的查询,每个部分的查询并发的运行,然后将各个部分的结果组合起来,提供最终的结果,多用于全表扫描,索引全 ...

  8. Vimim是VI中最好的输入法

    Vimim是VI中最好的输入法 由于在VI中,normal和insert模式的存在,如果在insert模式下正在输入中文,在通过ESC键返回到normal模式后,系统的中文输入法会与VI的命令相冲突, ...

  9. vue watch深度监听对象,实现数据联动

    当对象内的某一个元素发生变化,判断对象另一元素,并进行赋值 <template> <input type="text" v-model="a.a1.a1 ...

  10. Java - 若try中有return语句,finally会执行吗?在return之前还是之后呢?

    会执行,在方法return动作之前,return语句执行之后,若finally中再有return语句,则此方法以finally的return作为最终返回,若finally中无return语句,则此方法 ...