首页 > 其他 > 详细

【HDU 5387】Clock

时间:2016-02-06 01:50:24      阅读:200      评论:0      收藏:0      [点我收藏+]

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;
}

【HDU 5387】Clock

原文:http://www.cnblogs.com/flipped/p/5183793.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!