"HDU 5387" Clock

Source: Internet
Author: User

Problem

Description

Give a time. (HH:MM:SS), should answer the angle between any of the Minute.hour.second hand
Notice that the answer must is not more than and not less than 0

Input

There is $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 A Ngle between hour and Minute,hour and second hand,minute and second hand.

Sample Input

400:00:0006:00:0012:54:5504:40:00

Sample Output

0 0 0 180 180 0 1391/24 1379/24 1/2 100 140 120

Hint

Test instructions: The angle of the hour, minute, and second hand at a given point in time (fractional, angular)

Analysis: To be continued ....

#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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.