1006 Tick and tick

Source: Internet
Author: User

1006 Questions:

Problem Description

The three hands of the clock is rotating every second and meeting all other many times everyday. Finally, they get bored of this and all of the them would like to stay away from the other. A Hand is happy if it's at least D degrees from any of the rest. You is to calculate what much time in a day and all the hands is happy.

Input

The input contains many test cases. Each of them have a single line with a real number D between 0 and inclusively. The input is terminated with a D of-1.

Output

For each D, print in a, the percentage of time, a, and all of the hands is happy, accurate up to 3 DECIM Al places.

Sample Input

012090-1

Sample Output

100.000 0.000 6.251

Ideas:

Requirements: The interval between the hour, minute, and second hand is greater than the total time of an angle (which is entered by the user) for the total time of the day.

This can be understood as:

1. We only need to work out the clock from 12 o'clock full (3 pointers coincident), to the next 12 o'clock full (3 pointers again coincident) This 12 hours of time, the interval between the 3 pointers is greater than the time to set the angle (that is, the number of seconds).

2. Since it is the number of seconds, we can count the 12 hours, that is, in 720 minutes, the number of seconds per minute, the position of the 3 pointers meet the requirements.

3. Thus, we calculate the angle at which the 3 pointers deviate from the 12 o'clock full position at the moment of h:m:s (H-minute S-second) (because it is convenient to calculate the relative angular difference of the 3 pointers, i.e. the interval of their distance):

First: The angular velocity of these 3 pointers:

    1. #define V_SEC 6.0//second hand angular speed: 6 degrees per second
    2. #define V_MIN 0.1//minute corner speed: 0.1 degrees per second
    3. #define V_hou 1.0/120//angular speed: 1/120 degrees per second

Then: These 3 pointers deviate from the 0 point angle:

    1. #define A_SEC s*6//second hand angle: 6*s
    2. #define A_min m*6+s*0.1//minute hand angle: 0.1 degrees *60s*m minutes +0.1 degrees *s seconds
    3. #define A_hou h*30+m*0.5+s/120.0//hour angle: 1/120 degrees *3600s*h hours +1/120 degrees *60s*m minutes +1/120*s seconds

4.

1006 Tick and tick

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.