B - Avoiding a disaster

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 x480) 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:M1H2:M2H3:M3 In each reading H1, H2, H3 represent the hours displayed ( 0 < H1, H2, H3 < 13), and M1, M2, M3 represent the minutes displayed ( 0M1, M2, M3 < 60).

If the number of minutes is less than 10, a leading 0 is perpended.

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

题意:时间 a  b  c  要求随意两个时间间隔相同  则输出中间的那个时间  否则输出 look at the sun      样例1     10  5  12  间隔分别是五
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <iostream>
#include <algorithm>
#include <deque>
#include <ctime>
using namespace std;

int main()
{
   int n,i,j,t,m,a,b,h1,h2,h3;
   int num[5];
   while(~scanf("%d",&n))
   {
       while(n--)
       {
           for(i=0;i<3;i++)
           {
               scanf("%d:%d",&a,&b);
               num[i]=(a)*60+b;
           }
           sort(num,num+3);
           h1=num[1]-num[0];
           h2=num[2]-num[1];
           h3=num[0]-num[2]+720;
           //cout<<num[0]<<‘ ‘<<num[1]<<‘ ‘<<num[2]<<endl;
           //cout<<h1<<"  "<<h2<<"  "<<h3<<endl;
           if(h1==h2&&h2==h3)
                printf("Look at the sun\n");
           else if(h1==h2&&h1!=h3)
            printf("The correct time is %d:%02d\n",num[1]/60,num[1]%60);
           else if(h2==h3&&h2!=h1)
            printf("The correct time is %d:%02d\n",num[2]/60,num[2]%60);   ///%02d
           else if(h3==h1&&h3!=h2)
            printf("The correct time is %d:%02d\n",num[0]/60,num[0]%60);
            else
                 printf("Look at the sun\n");
       }
   }

   return 0;
}

B - Avoiding a disaster

时间: 2024-10-28 13:22:49

B - Avoiding a disaster的相关文章

[kaggle入门] Titanic Machine Learning from Disaster

Titanic Data Science Solutions¶ https://www.kaggle.com/startupsci/titanic-data-science-solutions 数据挖掘竞赛七个步骤:¶ Question or problem definition. Acquire training and testing data. Wrangle, prepare, cleanse the data. Analyze, identify patterns, and explo

SharePoint 2013 Disaster Recovery——迁移内容数据库

安装和配置SharePoint Farm时,一定要注意将内容数据库不要放在C盘,除非你的C盘能足够承受起日益增长的数据.由于在安装SQL SERVER中没有注意,我将数据库存放在默认的 C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA文件夹中.这时不幸的事情发生了,内容数据库增长过快直到将C盘撑暴,导致SharePoint Server发生意外故障. 所以,迁移内容数据库势在必行了. PowerShell查看

Avoiding PostgreSQL database corruption

TL;DR: Don't ever set fsync=off, don't kill -9 the postmaster then deletepostmaster.pid, don't run PostgreSQL on network file systems. Reports of database corruption on the PostgreSQL mailing list are uncommon, but hardly rare. While a few data corru

[转]Avoiding GDB Signal Noise.

原文:http://peeterjoot.wordpress.com/2010/07/07/avoiding-gdb-signal-noise/ A quick note for future reference (recorded elsewhere and subsequently lost). Suppose your program handles a signal that gdb intercepts by default, like the following example (g

机器学习案例学习【每周一例】之 Titanic: Machine Learning from Disaster

https://zhuanlan.zhihu.com/p/25185856 [Kaggle实例分析]Titanic Machine Learning from Disasterhttp://blog.csdn.net/wiking__acm/article/details/42742961 Titanic: Machine Learning from Disaster(Kaggle 数据挖掘竞赛)http://blog.csdn.net/han_xiaoyang/article/details/

High Availability (HA) 和 Disaster Recovery (DR) 的区别

High availability 和disaster recovery不是一回事. 尽管在规划和解决方案上有重叠的部分, 它们俩都是business contiunity的子集. HA的目的是在主数据中心内部, 提供弹性(resiliency)支持和计划允许内的宕机的时间. DR的目的是使得一个组织能在第一个数据中心发生灾难且影响到了基础设施的可用性的时候, 在第二个数据中心恢复计算机的正常使用.   High availability and disaster recovery are no

避免SIGPIPE导致的iOS应用闪退/Avoiding SIGPIPE signal crash in iOS(mach_msg_trap、SIGPIPE信号)

问题描述: 应用运行时,锁屏后再打开有一定几率闪退.通过真机调试发现程序会中断在此处: libsystem_kernel.dylib`mach_msg_trap: 解决思路: 通过这篇文章了解是进程收到 SIGPIPE  信号,该信号默认行为是终止进程. The process received a SIGPIPE . The default behaviour for this signal is to end the process. A SIGPIPE is sent to a proce

Performing a full database disaster recovery with RMAN

Performing a full database disaster recovery with RMAN1. Make the RMAN backup set pieces available.2. Restore the database spfile from autobackups.  --先恢复参数文件3. Restore the control file from autobackups.--再恢复控制文件4. Run the RMAN restore and recover co

JavaScript Patterns 2.7 Avoiding Implied Typecasting

Dealing with == and === false == 0 or "" == 0 return true. always use the === and !== operators that check both the values and the type of the expressions you compare: var zero = 0; if (zero === false) { // not executing because zero is 0, not f