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