/*m点n分k秒时
时针从0点转过的角度a = [m + n/60 + k/3600]*30
= 30m + n/2 + k/120(度)
分针转过的角度b = [n/60 + k/3600]*360
= 6n + k/10(度) */
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define MAXN 10
using namespace std;
struct node
{
int h,m;
double angle;
}times[MAXN];
int cmp(node x,node y)
{
if(fabs(x.angle-y.angle)<1e-6)//注意浮点数大小比较
{
if(x.h==y.h)
return x.m<y.m;
else
return x.h<y.h;
}
else
return x.angle<y.angle;
}
int main()
{
int test,i;
scanf("%d",&test);
while(test--)
{
for (i=0;i<5;++i)
{
scanf("%d:%d",×[i].h,×[i].m);
if(times[i].h>12)
times[i].angle=fabs(30.0*(times[i].h-12)+times[i].m/2.0-6.0*times[i].m);
else
times[i].angle=fabs(30.0*times[i].h+times[i].m/2.0-6.0*times[i].m);
if(times[i].angle>180)
times[i].angle=360-times[i].angle;
}
sort(times,times+5,cmp);
printf("%02d:%02d\n",times[2].h,times[2].m);
}
return 0;
}
hdu1209 Clock
最新推荐文章于 2020-09-20 17:01:48 发布