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 
 
 
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<math.h>
  4. int main()
  5. {
  6. int t;
  7. scanf("%d",&t);
  8. while(t--)
  9. {
  10. char c1,c2,c3;
  11. int h1,h2,h3;
  12. char m11,m12,m21,m22,m31,m32;
  13. scanf("%d%c%c%c",&h1,&c1,&m11,&m12);
  14. getchar();
  15. scanf("%d%c%c%c",&h2,&c2,&m21,&m22);
  16. getchar();
  17. scanf("%d%c%c%c",&h3,&c3,&m31,&m32);
  18. int min1=,min2=,min3=;
  19. min1=h1*+m11*+m12;
  20. min2=h2*+m21*+m22;
  21. min3=h3*+m31*+m32;
  22. int p1=,p2=,p3=;
  23. if(min1+min2==*min3&&fabs(min1-min3)<=)
  24. p3++;
  25. else if(min1+min3==*min2&&fabs(min1-min2)<=)
  26. p2++;
  27. else if(min3+min2==*min1&&fabs(min3-min1)<=)
  28. p1++;
  29. min1+=*;
  30. if(min1+min2==*min3&&fabs(min1-min3)<=)
  31. p3++;
  32. else if(min1+min3==*min2&&fabs(min1-min2)<=)
  33. p2++;
  34. else if(min3+min2==*min1&&fabs(min3-min1)<=)
  35. p1++;
  36. min1-=*;
  37. min2+=*;
  38. if(min1+min2==*min3&&fabs(min1-min3)<=)
  39. p3++;
  40. else if(min1+min3==*min2&&fabs(min1-min2)<=)
  41. p2++;
  42. else if(min3+min2==*min1&&fabs(min3-min1)<=)
  43. p1++;
  44. min2-=*;
  45. min3+=*;
  46. if(min1+min2==*min3&&fabs(min1-min3)<=)
  47. p3++;
  48. else if(min1+min3==*min2&&fabs(min1-min2)<=)
  49. p2++;
  50. else if(min3+min2==*min1&&fabs(min3-min1)<=)
  51. p1++;
  52. min1+=*;
  53. min2+=*;
  54. min3-=*;
  55. if(min1+min2==*min3&&fabs(min1-min3)<=)
  56. p3++;
  57. else if(min1+min3==*min2&&fabs(min1-min2)<=)
  58. p2++;
  59. else if(min3+min2==*min1&&fabs(min3-min1)<=)
  60. p1++;
  61. min2-=*;
  62. min3+=*;
  63. if(min1+min2==*min3&&fabs(min1-min3)<=)
  64. p3++;
  65. else if(min1+min3==*min2&&fabs(min1-min2)<=)
  66. p2++;
  67. else if(min3+min2==*min1&&fabs(min3-min1)<=)
  68. p1++;
  69. min1-=*;
  70. min2+=*;
  71. if(min1+min2==*min3&&fabs(min1-min3)<=)
  72. p3++;
  73. else if(min1+min3==*min2&&fabs(min1-min2)<=)
  74. p2++;
  75. else if(min3+min2==*min1&&fabs(min3-min1)<=)
  76. p1++;
  77. min1+=*;
  78. if(min1+min2==*min3&&fabs(min1-min3)<=)
  79. p3++;
  80. else if(min1+min3==*min2&&fabs(min1-min2)<=)
  81. p2++;
  82. else if(min3+min2==*min1&&fabs(min3-min1)<=)
  83. p1++;
  84. if(p1>&&p2>||p1>&&p3>||p2>&&p3>)
  85. printf("Look at the sun\n");
  86. else if(p1>)
  87. {
  88. printf("The correct time is %d:%c%c\n",h1,m11,m12);
  89. }
  90. else if(p2>)
  91. {
  92. printf("The correct time is %d:%c%c\n",h2,m21,m22);
  93. }
  94. else if(p3>)
  95. {
  96. printf("The correct time is %d:%c%c\n",h3,m31,m32);
  97. }
  98. }
  99. return ;
  100. }

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. 8. String to Integer

    Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. ...

  2. Producer & Consumer

    需要与Eureka结合使用 Eureka环境搭建 Producer 一.pom文件 <?xml version="1.0" encoding="UTF-8" ...

  3. POI对EXCEL的操作【重点:如何设置CELL格式为文本格式】

    实际开发过程中通常用到的就是从数据库导出EXCEL表格了,JXL可以这样做,其实POI也可以(关于JXL与POI的异同可访问我之前总结的文章),之前写过POI对七种文档(当然也包括EXCEL)的内容读 ...

  4. 【HHHOJ】NOIP2018 模拟赛(二十五) 解题报告

    点此进入比赛 得分: \(100+100+20=220\)(\(T1\)打了两个小时,以至于\(T3\)没时间打了,无奈交暴力) 排名: \(Rank\ 8\) \(Rating\):\(+19\) ...

  5. linux中管道(pipe)一谈

    /*********************************************** 管道(pipe)是Linux上进程间通信的一种方式,其是半双工(数据流只能在一个方向上流动(还需要经过 ...

  6. 十六、MySQL LIKE 子句

    MySQL LIKE 子句 我们知道在 MySQL 中使用 SQL SELECT 命令来读取数据, 同时我们可以在 SELECT 语句中使用 WHERE 子句来获取指定的记录. WHERE 子句中可以 ...

  7. 了解并使用springAOP(面向切面编程)

    Aop是干嘛的为什么要使用它 在业务系统中,总有一些散落,渗透到系统的各处且不得不处理的事情,这些穿插在既定业务中的操作就是所谓的“横切逻辑”,也称切面, 我们怎样才不受这些附加要求的干扰,专心于真正 ...

  8. 在生产环境下实现每天自动备份mysql数据库

    1.描述 我相信很多朋友在工作都都会有这种需求,老板或领导让你每天都要备份mysql数据库,你该如何实现呢,是每天到一定的时间在服务器上敲一遍mysql的备份命令,还是想写个脚本,定时定点的自动备份呢 ...

  9. 【PHP】根据两地经纬度计算距离

    最近做一个H5活动的项目,有个要求是必须现场玩家才能参与,所以就需要计算玩家位置和活动地点的距离来判断是否在活动现场. 以下是写的一个根据经纬度计算两地距离的方法 1 function getDist ...

  10. hive的常用HQL语句

    1.过滤条件 where .limit. distinct. between and . null. is not nullselect * from emp where sal > 3000; ...