题
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
There are $T$$(1leq T leq 10^4)$ test cases for each case,one line include the time $0leq hh<24$,$0leq mm<60$,$0leq 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 120
Hint
代码语言:javascript复制每行输出数据末尾均应带有空格
题意:
求给定时间点的时针、分针、秒针的夹角(分数、角度制)
分析:
tol=总秒数,时针1/120 °/s,分针1/10 °/s,秒针 6 °/s,
分针和时针转过的角度差(tol/10-tol/120)=11*tol/120;
秒针和时针转过的角度差(6*tol-tol/120)=719*tol/120;
秒针和分针转过的角度差(6*tol-tol/10)=59*tol/10;
然后前两个角度差的分子%(120*360)即C200,后面一个600,这样就<360了,就是我们要求的夹角或其补角了。
然后判断夹角up/down 是否大于180度,刚开始我让它>180就360减去它,但是 这里是整除,也就是180多一点点的整除了变成180,所以要写成>=180或>179时就让360减去它。
接下来约分输出。
代码:
代码语言:javascript复制 1 #include<stdio.h>
2 int t,h,m,s,tol,up[4],down[4],g;
3 int gcd(int a,int b)
4 {return b?gcd(b,a%b):a;}
5 int main()
6 {
7 scanf("%d",&t);
8 while(t--)
9 {
10 scanf("%d:%d:%d",&h,&m,&s);
11 tol=h*3600 m*60 s;
12 up[0]=(11*tol)%(43200);
13 up[1]=(719*tol)%(43200);
14 up[2]=(59*tol)%(3600);
15 down[0]=down[1]=120;down[2]=10;
16 for(int i=0; i<3; i )
17 {
18 g=gcd(up[i],down[i]);
19 up[i]/=g;down[i]/=g;
20 if(up[i]/down[i]>179)up[i]=down[i]*360-up[i];
21 if(down[i]==1)printf("%d ",up[i]);
22 else printf("%d/%d ",up[i],down[i]);
23 }
24 printf("n");
25 }
26 return 0;
27 }