Pow #2 locker vandalismLong ago,Aptos wasn’t the nice,friendly school as we know of today.One day,these wicked adolescents decided to play a trick on the principal.They decided to vandalize the school’s 1,000 lockers by opening and closing them one after another.They had a love of mathematics,so they devised a plan to open and close the lockers in a systematic pattern.Here was their plan:the lockers were numbered 1-1,000.The first student would start

问题描述:

Pow #2 locker vandalism
Long ago,Aptos wasn’t the nice,friendly school as we know of today.One day,these wicked adolescents decided to play a trick on the principal.They decided to vandalize the school’s 1,000 lockers by opening and closing them one after another.They had a love of mathematics,so they devised a plan to open and close the lockers in a systematic pattern.
Here was their plan:the lockers were numbered 1-1,000.The first student would start with locker #1 to open every locker.The second student would then go to locker #2 and close every other locker all the way to locker #1,000.The third student would then take her turn.Starting with locker #3,she would change the position of the door to every third locker all the way to #1,000.That is,if the door were open,she’d close it,and if it were closed,she’d open it.Then the fourth student could go to locker #4,change its position,and change its position,and change its position of every fourth locker through #1,000.This pattern continued until all 1,000 students had taken a turn.
When they finished,they looked over what they had done,hoping to see utter chaos… But they were shocked!
What did they see?
Which lockers were open and which lockers were closed?

最后打开的锁为平方数:1,4,9,16,25 ,.
关闭的锁为其他锁
因为完全平方数的因子个数为奇数,相当于奇数次打开,最后为打开的状态
而非完全平方数的因子个数为偶数,相当于偶数次打开,最后为关闭的状态