hdu5387 六校 Clock(水题 模拟)
2015-08-14 14:30
204 查看
题目链接
http://acm.hdu.edu.cn/showproblem.php?pid=5387
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 370 Accepted Submission(s): 255
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每行输出数据末尾均应带有空格
一道比较水的题=,=,稍微用到了一点计算几何的东西
AC代码
http://acm.hdu.edu.cn/showproblem.php?pid=5387
Clock
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 370 Accepted Submission(s): 255
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每行输出数据末尾均应带有空格
一道比较水的题=,=,稍微用到了一点计算几何的东西
AC代码
#include<stdio.h> #include<math.h> #define eps 1e-8 int com(double m) { if(fabs(m)<eps) return 0; if(m<0) return -1; return 1; } void print2(double k) { for(int i=1;i<=360;i++) { if(com((i*k)-int(i*k+0.5))==0){ if(i==1) printf("%d ",int(i*k)); else printf("%d/%d ",int(i*k+0.5),i); return; } } } void print(double x,double y) { double k; k=fabs(x-y); if(k>=180) k=360-k; print2(k); } int main() { int hour,t; double h,m,s,minn,sec; scanf("%d",&t); while(t--) { scanf("%d:%lf:%lf",&hour,&minn,&sec); h=hour%12*30+minn*0.5+sec/120; m=minn*6+sec*0.1; s=sec*6; print(h,m); print(h,s); print(m,s); printf("\n"); } }
相关文章推荐
- HDU 1568
- HDU1290
- HDU1568(Fobonacci公式)
- HDU ACM Step 2.2.2 Joseph(约瑟夫环问题)
- HDU 1405
- HDU 1297
- hdu 1205
- hdu 2087
- hdu 1016
- HDU 4898 The Revenge of the Princess’ Knight ( 2014 Multi-University Training Contest 4 )
- HDU 1000
- HDU 1001
- HDU 1622 Trees On The Level
- HDU 1063 Exponentiation
- Hdu5033
- HDU 1166 敌兵布阵
- HDU Rightmost Digit
- hdu 1002
- 贪心 hdu 1003
- hdu 1004