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. [动态规划] uestc oj A - 男神的礼物

    A - 男神的礼物 Time Limit: 3000/3000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Lweb学长 ...

  2. Linux系统运维常见面试简答题(36题)

    1.请描述下linux 系统的开机启动过程开机加电BIOS自检———–>MBR引导———–>grub引导菜单———–>加载内核———–>启动init进程———–>读取in ...

  3. 2018.6.22 Java试题测试结果

    如何从有数字规律的网址抓取网页并保存在当前目录?假设网址为 http://test/0.xml,其中这个数字可以递增到100. for((i=0;i<100;++i));do wget http ...

  4. Oracle表连接学习笔记

    目录 一.表连接类型 1.1 内连接 1.2 外连接 二.表连接方法 2.1 表连接方法分类 2.2 表连接方法特性区别 @ 一.表连接类型 表连接类型可以分为:内连接.外连接,在看<收获,不止 ...

  5. 自建ssr(谷歌云免费试用一年)

    近期我一个朋友的VPN到期了,他也不想再去续费,同时发现谷歌云第一年申请时是免费的,所以他就自己搭建了一个自己专属的VPN 以下是他的搭建教程:  本教程难点在于申请免费试用资格 谷歌云+ssr搭建免 ...

  6. Bootstrap 历练实例 - 折叠(Collapse)插件方法

    方法 下面是一些折叠(Collapse)插件中有用的方法: 方法 描述 实例 Options:.collapse(options) 激活内容为可折叠元素.接受一个可选的 options 对象. $(' ...

  7. HDU-3366-Count the string(KMP,DP)

    Count the string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...

  8. Vue入门之HelloWorld

    对于新学习一门技术,一门语言比如JAVA.Python等都是从编写Hello World开始的,这样一来有益于初学者的人门,并给予初学者一定的信心,所以我也从HelloWorld开始讲起. 干货: 对 ...

  9. 项目十八-Hadoop+Hbase分布式集群架构“完全篇”

    本文收录在Linux运维企业架构实战系列 前言:本篇博客是博主踩过无数坑,反复查阅资料,一步步搭建,操作完成后整理的个人心得,分享给大家~~~ 1.认识Hadoop和Hbase 1.1 hadoop简 ...

  10. Android Studio 3.0 安装注意点

    在安装Android studio 3.0+ 时候,会遇到默认不带Android SDK 的问题. 在启动Android studio 后,会提示让选择SDK目录,选择下载目录,对应的去下载 那么问题 ...