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$$(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 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
每行输出数据末尾均应带有空格
题意:求给定时间点的时针、分针、秒针的夹角(分数、角度制)
分析:待续....
#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; }
时间: 2024-10-13 09:23:05