返回题库

100 盏灯

100 Light bulbs

专题
General / 综合
难度
L2

题目详情

有 100 盏灯初始都关着。第 1 轮:把所有灯的开关切换一次;第 2 轮:每隔 1 盏切换一次(切换第 2,4,6,... 盏);第 3 轮:切换第 3,6,9,... 盏;……第 100 轮:只切换第 100 盏。

问:最后哪些灯是亮着的?

There are 100 Light bulbs in a sequence, all kept in OFF state. The first person comes and toggles all the bulbs which are at position that is multiple of 11, i.e. switch all bulbs to ON. The second person toggles all multiples of 22, i.e. turn the even numbered bulbs OFF and leave the odd ones as is. The third person comes and toggles all multiples of 33. This process continues till the 100th100^{\text{th}} person do their part. After this, how many bulbs are in ON state?

Hint

Consider bulb number 1 and 4, how is its outcome different than the others.

解析

编号为完全平方数的灯会亮着:1,4,9,16,,1001,4,9,16,\dots,100

原因:第 kk 盏灯会在所有能整除 kk 的轮次被切换一次,总切换次数等于 kk 的因子个数。只有完全平方数的因子个数为奇数(因为 k\sqrt{k} 这一因子成对合并后会“单独剩一个”),因此只有完全平方数最后保持“开”。


Original Explanation

10 bulbs

Solution

Observation

Draw a small grid of 6x6 on a piece of paper and simulate the outcome.

Observe that each bulb is toggled as many times as many unique divisors it has. For example, bulb number 6 has divisors [1,2,3,6], so it is toggled back and forth by person number [1,2,3,6], i.e, 4 times.

In this case, only the bulb number 11 and 44 are ON at the end of 6 steps, and they have odd number of divisors. Can it be that perfect square number have odd unique divisors?

Checking for some more numbers:

  • Divisors for 99 are [1,3,9][1,3,9], hence 33 toggles
  • Divisors for 1616 are [1,2,4,8,16][1,2,4,8,16], hence 55 toggles

Hence we form a conjecture: For perfect squared numbers, the count of unique factors is always odd.

Proof: Divisors are always found in pairs. For number KK if we find one divisor d1d_1 then we also just found another divisor d2=K/d1d_2 = K/d_1. The divisor count would increase by 2, unless d1=d2d_1 = d_2 which happens exactly once for a perfect square and never for any other number.

Note that for a non-square number, the count of unique divisors are always even.

A bulb at position KK is toggled between ON / OFF states only by the person whose number is divisor of KK. When KK is a perfect square number then the bulb will be ON at the end because of the odd sequence of toggling. For all the other numbers, the bulb will be OFF because of the even sequence of toggling.

Thus bulbs 1,4,9....81,100 are ON, at the end.

Hence 10 bulbs are on.

Generalization

If there are nn bulbs in a sequence and nn people, then the number of bulbs that are ON at the end is n\lfloor \sqrt{n} \rfloor

Divisor Formula

Let nn be a positive integer and n=p1e1p2e2pkekn = p_1^{e_1} \cdot p_2^{e_2} \cdots p_k^{e_k} is the prime factorization of nn

In how many different ways can we form a divisor?

Let dd be a divisor of nn, d=p1a1p2a2pkakd = p_1^{a_1} \cdot p_2^{a_2} \cdots p_k^{a_k} where 0aiei0 \le a_i \le e_i.

Thus, there are ei+1e_i + 1 choices for each prime factor pip_i, indepdently for each ii.

Thus, the total number of divisors of nn is given by

τ(n)=(e1+1)(e2+1)(ek+1)\tau(n) = (e_1 + 1)(e_2 + 1) \cdots (e_k + 1)

If nn is a perfect square, then each eie_i is even, so ei+1e_i + 1 is odd. Therefore, the product (e1+1)(e2+1)(ek+1)(e_1 + 1)(e_2 + 1) \cdots (e_k + 1) is odd.