Clock


Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 182    Accepted Submission(s): 129



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


 



Input


T (1≤T≤104) test cases
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


Hint

每行输出数据末尾均应带有空格



 



Source


2015 Multi-University Training Contest 8









求得夹角必须都是小于180度的






点击打开链接


#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<stack>
#include<map>

using namespace std;

int x,y,z;

int gcd(int x, int y)
{
    if (x%y) return gcd(y, x%y);
    return y;
}


int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d:%d:%d",&x,&y,&z);
        int zz = z*6*120;
        int yy = (y*60+z)*12;///角度*10
        int xx = ((x%12)*3600 + y*60 + z);///角度*120
        int xy = abs(xx - yy);
        int xz = abs(xx - zz);
        int yz = abs(yy - zz);
        if(xy>120*180)
        {
            xy = 360*120 - xy;
        }
        if(xz > 120*180)
        {
            xz = 360*120 - xz;
        }
        if(yz > 120 * 180)
        {
            yz = 360*120 - yz;
        }
        if(xy%120 == 0)
        {
            printf("%d ",xy/120);
        }
        else
        {
            int pp = gcd(xy,120);
            printf("%d/%d ",xy/pp,120/pp);
        }
        if(xz%120 == 0)
        {
            printf("%d ",xz/120);
        }
        else
        {
            int pp = gcd(xz,120);
            printf("%d/%d ",xz/pp,120/pp);
        }
        if(yz%120 == 0)
        {

            printf("%d ",yz/120);
        }
        else
        {
            int pp = gcd(yz,120);
            printf("%d/%d ",yz/pp,120/pp);
        }
        printf("\n");


    }
    return 0;
}