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 ;
}

最新文章

  1. Web接口测试工具---Poster与Postman
  2. PHP中如何在数组中随机抽取n个数据的值 - array_rand()?
  3. EDIUS和VEGAS哪个更好用
  4. [转帖]了解AmbiLight知识
  5. STL的移动算法
  6. LR错误整理
  7. log4j.rootLogger详细说明
  8. c#.net的网站出现“正在中止线程””异常的原因和解决方法
  9. ABP Zero 多租户管理
  10. 关于OELD屏显示电池电量的简易方法
  11. STM32F429学习笔记(一)触屏工程Keil建立
  12. [转]国家税务总局:个税专项附加扣除APP正式启用!(附操作指南)
  13. 使用WebStorm报错 Namespace &#39;v-bind&#39; is not bound
  14. Linux应用和系统库的2种安装方式---源码安装tarball和二进制rpm包
  15. Python面向对象-day07
  16. Java生成代码(字节码)
  17. Python的浅拷贝与深拷贝
  18. 0_Simple__template
  19. 基于CUDA的粒子系统的实现
  20. jira-source--plugin

热门文章

  1. java设计模式、框架、架构、平台之间的关系
  2. Android(java)学习笔记96:layout_weight使用注意事项
  3. IBM中国
  4. 2018.10.29 NOIP2018模拟赛 解题报告
  5. 选中ListBox控件中的全部项
  6. 漫谈 Clustering (番外篇): Vector Quantization
  7. Java 程序设计总复习题
  8. for in 和 for of的区别详解
  9. Linux 服务器用户权限管理改造方案与实施项目
  10. FZU 2082 过路费(树链剖分)