12小时内时针分针重合几次?

1.试试一段小的python代码来理清思路

for hour in range(0, 11, 1):
       for minute in range(0, 59, 1):
              m_angle = minute * 360/60
              h_angle = hour * 360/12 + 360/12/60 * minute    # in this case, '/' is integer divider
              if m_angle == h_angle:  # integer approx. comparing
              print hour, round(30/5.5 * hour, 1) # 30hour + 0.5minute = 6minute, solve minute=30/5.5hour

2. 上述代码里算角度的除法实际上得到的是integer,因此if判断语句得到的(hour,miute)结果并不是真正重合的时间,只是过了这个时间后很快就有一次重合

3. 通过代码也理清了思路,实际上每小时都会有一次重合,至于是什么时间重合,实际上是解下面这个方程:

m_angle = h_angle

minute * 360/60 = hour * 360/12 + 360/12/60 * minute

-> minute = 60/11 * hour

举例:3点以后第一次重合是什么时候?

minute = 60/11 * 3

minute = 16.36

也就是3点16分22秒左右会重合

4. 所以代码的最后语句中, print也改成了会重合的具体时间,结果如下:结构(小时 分)

0 0.0
1 5.5
2 10.9
3 16.4
4 21.8
5 27.3
6 32.7
7 38.2
8 43.6
9 49.1
10 54.5

一共11次

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s