Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1320 Accepted Submission(s): 601
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
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
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
每行输出数据末尾均应带有空格
1 #include <stdio.h> 2 3 int main() 4 { 5 int T; 6 int i,j,k,t; 7 char s[10]; 8 scanf("%d",&T); 9 while(T--) 10 { 11 t=0; 12 scanf("%s",s); 13 t=t+(s[7]-‘0‘)+(s[6]-‘0‘)*10; 14 t=t+((s[4]-‘0‘)+(s[3]-‘0‘)*10)*60; 15 t=t+((s[1]-‘0‘)+(s[0]-‘0‘)*10)*3600; 16 //printf("t:%d\n",t); 17 int a,A,b,B,c; 18 c=(t*6)%360; 19 b=t%3600,B=10; 20 a=t%(120*360),A=120; 21 //printf("a:%d b:%d c:%d\n",a,b,c); 22 23 int x,y; 24 y=120; 25 if(b*12-a>=0) 26 x=b*12-a; 27 else 28 x=a-b*12; 29 if(x>(120*180)) 30 { 31 x=120*360-x; 32 } 33 if(x%120==0) 34 printf("%d ",x/120); 35 else 36 { 37 while(x%2==0 && y%2==0) 38 { 39 x=x/2,y=y/2; 40 } 41 while(x%3==0 && y%3==0) 42 { 43 x=x/3,y=y/3; 44 } 45 while(x%5==0 && y%5==0) 46 { 47 x=x/5,y=y/5; 48 } 49 printf("%d/%d ",x,y); 50 } 51 52 y=120; 53 if(c*120-a>=0) 54 x=c*120-a; 55 else 56 x=a-c*120; 57 if(x>(120*180)) 58 { 59 x=120*360-x; 60 } 61 if(x%120==0) 62 printf("%d ",x/120); 63 else 64 { 65 while(x%2==0 && y%2==0) 66 { 67 x=x/2,y=y/2; 68 } 69 while(x%3==0 && y%3==0) 70 { 71 x=x/3,y=y/3; 72 } 73 while(x%5==0 && y%5==0) 74 { 75 x=x/5,y=y/5; 76 } 77 printf("%d/%d ",x,y); 78 } 79 80 y=10; 81 if(c*10-b>=0) 82 x=c*10-b; 83 else 84 x=b-c*10; 85 if(x>(10*180)) 86 { 87 x=10*360-x; 88 } 89 //printf("x:%d\n",x); 90 if(x%10==0) 91 printf("%d ",x/10); 92 else 93 { 94 while(x%2==0 && y%2==0) 95 { 96 x=x/2,y=y/2; 97 } 98 while(x%5==0 && y%5==0) 99 { 100 x=x/5,y=y/5; 101 } 102 printf("%d/%d ",x,y); 103 } 104 printf("\n"); 105 } 106 return 0; 107 }
时间: 2024-10-18 18:29:08