#include <iostream> #include <algorithm> #include <cstring> #include <math.h> #include < Stdio.h> #include <map>using namespace std;int gcd (int x,int y) {return y==0?x:gcd (y,x%y);} int main () {int h,m,s; int x,y,z,t; int gx,gy,gz; scanf ("%d", &t); while (t--) {scanf ("%d:%d:%d", &x,&y,&z); x%=12; Enlarge the angle by 120 times times to eliminate the denominator h=3600*x+60*y+z;//h=120* (30* (x+y/60+z/3600) +10* (Y+Z/60) +6*z) m=720*y+12*z; S=720*z; X=abs (H-M); Y=abs (h-s); Z=abs (m-s); if (180*120<x) x=360*120-x; if (180*120<y) y=360*120-y; if (180*120<z) z=360*120-z; GX=GCD (x,120); GY=GCD (y,120); GZ=GCD (z,120); if (gx==120) printf ("%d", X/GX); else printf ("%d/%d", X/GX,120/GX); if (gy==120) printf ("%d", y/gy); else printf ("%d/%d", y/gy,120/gy); if (gz==120) printf ("%d", z/gz); else printf ("%d/%d", z/gz,120/gz); printf ("\ n"); } return 0;}
HDU 5387 Clock (analog)