Locker Mania - Answer

Although there were solutions to this provided by Murali and Eric in the comments section and they are correct. Just posting it here for more general viewing. BTW, I went through the C program written by Eric, it was really nicely written program with neat output as well. Really nice!

 Anyway back to the answer.

The state of any locker N will remain unchanged from the beginining as long as N = P \* Q, and P and Q happen to be distinct (There can be multiple combinations of P and Q). That means, given the 10th locker, its state will be toggled by the 1st and the 10th member. Its state will again be toggled  by the 2nd member and then again by the 5th member, thus its state remaining unchanged. This is since the factors of 10 are (1,10) and (2,5)

 For locker number N where N =P\*Q, and P and Q are same, i.e locker numbers which are perfect squares, there will only be one state change and hence are the ones which will remain open in the end.

Example, locker number 9. Its state will be changed by (1,9) member and again by the (3,3). But since the 3rd member can only toggle once, we can see that the state if the 9th locker will be open ultimately. Same for all perfect squared numbered locker till 100.

 

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

insidemyhead

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today