2680

/*
	有关时针和分针夹角的问题
*/

// include file
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>

#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>

#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <functional>

using namespace std;

// typedef

// 
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)

#define Z(a,b) ((a)<<(b))
#define Y(a,b) ((a)>>(b))

const double eps = 1e-6;
const double INFf = 1e100;
const int INFi = 1000000000;
const double Pi = acos(-1.0);

template<class T> inline T sqr(T a){return a*a;}
template<class T> inline T TMAX(T x,T y)
{
	if(x>y) return x;
	return y;
}
template<class T> inline T TMIN(T x,T y)
{
	if(x<y) return x;
	return y;
}
template<class T> inline T MMAX(T x,T y,T z)
{
	return TMAX(TMAX(x,y),z);
}
template<class T> inline T MMIN(T x,T y,T z)
{
	return TMIN(TMIN(x,y),z);
}
template<class T> inline void SWAP(T &x,T &y)
{
	T t = x;
	x = y;
	y = t;
}


// code begin
struct node
{
	int hh;
	int mm;
	double angle;
	int ss;
	friend bool operator<(node a,node b)
	{
		if( fabs(a.angle-b.angle)<eps)
			return a.ss<b.ss;
		return a.angle<b.angle;
	}
}dt[5];
int N;
double angle(int hh,int mm)
{
	double first = hh*30+(mm*60.0)/3600.*30.;
	if(first>=360.0) first-=360.0;
	
	double second = (mm*60.0)/3600.*360.0;
	double ans = abs(first-second);
	if(ans>=180.0) ans = 360.0-ans;
	return ans;
}
int main()
{
	read;
	write;
	scanf("%d",&N);
	while(N--)
	{
		for(int i=0;i<5;i++)
		{
			scanf("%d:%d",&dt[i].hh,&dt[i].mm);
			dt[i].ss = dt[i].hh*3600+dt[i].mm*60;
			dt[i].angle = angle(dt[i].hh,dt[i].mm);
			//printf("%f\n",dt[i].angle);
		}
		sort(dt,dt+5);
		printf("%02d:%02d\n",dt[2].hh,dt[2].mm);
	}
	return 0;
}
posted @ 2011-05-02 15:51  AC2012  阅读(162)  评论(0编辑  收藏  举报