Problem
Description
Give a time. (HH:MM:SS), should answer the angle between any of the Minute.hour.second hand
Notice that the answer must is not more than and not less than 0
Input
There is $T $$ (1\leq T \leq 10^4) $ test Cases
For each case,one line include the time
$0\leq Hh<24$,$0\leq Mm<60$,$0\leq 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 A Ngle between hour and Minute,hour and second hand,minute and second hand.
Sample Input
400:00:0006:00:0012:54:5504:40:00
Sample Output
0 0 0 180 180 0 1391/24 1379/24 1/2 100 140 120
Hint
Test instructions: The angle of the hour, minute, and second hand at a given point in time (fractional, angular)
Analysis: To be continued ....
#include <stdio.h>int t,h,m,s,tol,up[4],down[4],g;int gcd (int a,int b) { return b?gcd (b,a%b): A;} int main () { scanf ("%d", &t); while (t--) { scanf ("%d:%d:%d", &h,&m,&s); Tol=h*3600+m*60+s; up[0]= (11*tol)% (43200); down[0]=120; up[1]= (719*tol)% (43200); down[1]=120; up[2]= (59*tol)% (3600); down[2]=10; for (int i=0; i<3; i++) { if (up[i]/down[i]>179) up[i]=down[i]*360-up[i]; G=GCD (Up[i],down[i]); up[i]/=g; down[i]/=g; if (down[i]==1) printf ("%d", Up[i]>180?360-up[i]:up[i]); else printf ("%d/%d", Up[i],down[i]); } printf ("\ n"); } return 0;}
"HDU 5387" Clock