Coincidence between the hour hand and second hand

Source: Internet
Author: User

Problem: The hour and second hands overlap several times within 24 hours

Analysis: This question seems a little scary, but if you think of it, you can kill it in seconds. First, you need to understand what is the coincidence between the hour hand and the second hand, because the second hand takes one cell in the clock, and the hour hand can be seen as a continuous rotation, here, we need to consider the coincidence at the moment when the second hand stops. Think of this, and then look at the hour hand if you want to overlap with the second hand, you must go to a grid, the second hand just went to this grid. It is known that a grid has 12 minutes. When the hour hand goes to each grid, it must be a whole minute, that is, the second hand must be. If they want to overlap, they will only arrive at 12 points at the same time. Within 24 hours, only the following time points are met: 0, 12, and 24. Therefore, it can only overlap three times in a day. That is to say, although the two will pass by each second, the only three times of real encounter in a day.

Verification: each time the hour hand goes through a grid of 6 degrees, and the second hand goes through 12 (m) * 60 (s) * 6 degrees. The coincidence between the two is equal to the two after the modulo of 360.

[Cpp]
Void Solve (){
Const int GRIDS = 24*5; // 24 hours; 5 grids per hour;
Const int DEGREE = 360;
Const int SECOND_OF_MINUTE = 60;
Const int DEGREE_OF_GRID = 6;
Const int SECOND_OF_GRID = 12 * SECOND_OF_MINUTE;

Int count = 0;
For (int I = 0; I <= GRIDS; ++ I ){
Int dh = (DEGREE_OF_GRID * I) % DEGREE;
Int ds = (DEGREE_OF_GRID * I * SECOND_OF_GRID) % DEGREE;
If (dh = ds) ++ count;
}
Printf ("% d \ n", count );
}
PS: Trend Micro, test, 2013, select

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.