#OLD279. Turn on and Turn off the lights
Turn on and Turn off the lights
Description
有N盏灯,编号为
1 ~ n
.第一个人把所有灯打开,第二个人按下所有编号为2的倍数的开关(这些灯将被关掉),第三个人按下所有编号为3的倍数的开关(其中关着的灯将被打开,开着的灯将被关闭),依次类推.一共有k个人,问最后还有哪些灯开着.
Format
Input
输入数据有多组,每组包含两个正整数 n 和 k (k <= n <= 1000), n 代表灯的个数, k 代表人的个数.
Output
输出最后开着的灯的编号.
Samples
7 3
1 5 6 7