#P8622. Toggle Lights on Biochip
Toggle Lights on Biochip
Toggle Lights on Biochip
Dr. X is researching a biochip whose logic density and capacity far exceed those of ordinary semiconductor chips. In his chip, he has designed \(n\) micro light sources. Each light source toggles its state (i.e. from off to on or on to off) each time it is operated. Initially, all light sources are off.
The doctor performs the following sequence of operations on the chip:
- Toggle every light source whose index is a multiple of \(2\) (i.e. indices: 2, 4, 6, 8, \(\ldots\)).
- Toggle every light source whose index is a multiple of \(3\) (i.e. indices: 3, 6, 9, \(\ldots\)). Note that if a light (for example, light 6) was on after the previous step, it will now be toggled off.
- Toggle every light source whose index is a multiple of \(4\).
- \(\vdots\)
- Toggle the light source whose index is a multiple of \(n\).
After executing these operations, Dr. X would like to know which light sources in a given interval \([L, R]\) are turned on. A light source is considered on if it has been toggled an odd number of times. Note that each light source \(i\) (where \(2 \le i \le n\)) gets toggled once for each divisor \(d\) (with \(2 \le d \le n\)) that divides \(i\). It can be shown that a light source \(i\) is on if and only if the total number of divisors of \(i\) is even, which happens precisely when \(i\) is not a perfect square (recall that a number has an odd number of divisors if and only if it is a perfect square). For \(i = 1\), no operations occur and it remains off.
Your task is, given \(n\) and an interval \([L, R]\), determine the indices of the light sources that are turned on after all operations.
inputFormat
The input consists of a single line containing three space-separated integers: \(n\), \(L\), and \(R\), where:
- \(n\) is the total number of light sources (indexed from 1 to \(n\)).
- \(L\) and \(R\) define the interval \([L, R]\) (with \(1 \le L \le R \le n\)) in which you must determine which lights are on.
outputFormat
Output the indices (in increasing order) of all light sources in the interval \([L, R]\) that are turned on, separated by a single space. If no light is on in the interval, output None
.
sample
10 1 10
2 3 5 6 7 8 10