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/2100 140 120
简单题,直接模拟就好了
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int base=12*60*60; const int maxn=1000005; int a[maxn],b[maxn],c[maxn],x,y,z,T; int gcd(int x,int y) { if (x%y) return gcd(y,x%y); return y; } void put(int x,char c) { if (x==0) printf("0%c",c); else { x=x*360; int y=gcd(x,base); if (y!=base) printf("%d/%d%c",x/y,base/y,c); else printf("%d%c",x/y,c); } } void putout(int x) { int m=base/2; int i=abs(a[x]-b[x]); int j=abs(a[x]-c[x]); int k=abs(b[x]-c[x]); if (i>m) i=base-i; if (j>m) j=base-j; if (k>m) k=base-k; put(i,' '); put(j,' '); put(k,' '); printf("\n"); } int main() { int tot=0; a[0]=b[0]=c[0]=0; for (int i=0;i<24;i++) for (int j=0;j<60;j++) for (int k=0;k<60;k++) { if (i+j+k==0) continue; tot++; a[tot]=(a[tot-1]+1)%base; b[tot]=(b[tot-1]+12)%base; c[tot]=(c[tot-1]+12*60)%base; } scanf("%d",&T); while (T--) { scanf("%d:%d:%d",&x,&y,&z); tot=x*60*60+y*60+z; putout(tot); } return 0; }