#t482. 开关灯
开关灯
Lights On and Off
Problem Description
Suppose there are lights ( is a positive integer not greater than ), numbered to in order, all initially turned on; and there are people ( is a positive integer not greater than ), also numbered to in order.
Person turns all the lights off. Person turns on the lights whose numbers are multiples of . Person flips the lights whose numbers are multiples of (i.e. turns on the ones that are off, and turns off the ones that are on). In increasing order of number, everyone after that behaves like person : each flips all the lights whose numbers are multiples of their own number.
After person has finished operating, which lights are off? Output their numbers in increasing order, separated by commas.
Input Format
Two positive integers and , separated by a single space.
Output Format
Output the numbers of the lights that are off, in order, separated by commas.
Sample Input
10 10
Sample Output
1,4,9
Hint
- A light ends up off if it is flipped an odd number of times. Think about which positions are flipped an odd number of times.
- The output uses a comma
,(not a space) to separate the numbers — check against the sample character by character.