Problem Description
Give a time.(hh:mm:ss),you should answer the angle between any two of the minute.hour.second hand
Notice that the answer must be not more 180 and not less than 0
Notice that the answer must be not more 180 and not less than 0
Input
There are
T
(1≤T≤104)
test cases
for each case,one line include the time
0≤hh<24 , 0≤mm<60 , 0≤ss<60
for each case,one line include the time
0≤hh<24 , 0≤mm<60 , 0≤ss<60
Output
for each case,output there real number like A/B.(A and B are coprime).if it's an integer then just print it.describe the angle between hour and minute,hour and second hand,minute and second hand.
Sample Input
4 00:00:00 06:00:00 12:54:55 04:40:00
Sample Output
0 0 0 180 180 0 1391/24 1379/24 1/2 100 140 120Hint每行输出数据末尾均应带有空格
分数gcd形式的写法
#include <cstdio>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
void gcd(int a,int b)
{
int aa=a;
int bb=b;
while(b!=0) {
int r=b;
b=a%b;
a=r;
}
printf("%d/%d ",aa/a,bb/a);
}
int main()
{
int t,h,m,s,a,b,c;
scanf("%d",&t);
while(t--)
{
scanf("%d:%d:%d",&h,&m,&s);
h%=12;
if(h==24)
h=0;
else if(h>12)
h=h-12;
h=h*3600+m*60+s;
m=m*720+s*12;
s*=720;
a=abs(h-m);
b=abs(h-s);
c=abs(m-s);
if(a>21600)
a=43200-a;
if(b>21600)
b=43200-b;
if(c>21600)
c=43200-c;
if(a%120)
gcd(a,120);
else
printf("%d ",a/120);
if(b%120)
gcd(b,120);
else
printf("%d ",b/120);
if(c%120)
gcd(c,120);
else
printf("%d ",c/120);
printf("\n");
}
return 0;
}