Toph easy problem(clock math)

Question:


Clock Math

Limits: 1s, 512 MB

Given a time (hours as H and minutes as M), determine the smaller angle between the two hands of a clock showing the time and print it.

Input

The input will contain two integers: H (0 ≤ H < 12) and M (0 ≤ M < 60).

Output

Print the angle in degrees (accurate to 10-4).

Samples

InputOutput
10 15

Solve in C:

#include<stdio.h>
int main()
{
    float d,s,t;
    int m,h;
    scanf("%d %d",&h,&m);
    {
        d=(11*m-60*h)/2.0;

        if(d>0&&d>180)
        {
            s=360-d;
            printf("%.7f\n",s);
        }
        else if(d>0&&181>d)
            printf("%.7f\n",d);

        else if(d<1)
        {
            s=(-1)*d;;
            if(s>180)
            {
                t=360-s;
                printf("%.7f\n",t);
            }
            else
                printf("%.7f\n",s);
        }
        return 0;

    }
}


142.5000000


No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.