Author: Manish Pathak
Tester: Manish Pathak
Editorialist: Manish Pathak
In a Chefland a robber entered into a bank and told the bank manager(i.e. Chef) to give him all the money.There are total N lockers in the bank.As you know that the Chef is very intelligent so he told the robber that he has an idea if you will follow me then we both will be in profit.
Chef told him that he can’t take money from all the lockers because if he will do so then the alarm will be on and you will be in trouble.
He told that i will do a total of N moves:-In my first move i will open all the lockers.
In my second move i will reverse the states of 2,4,6… lockers.
In my third move i will reverse the states of 3,6,9… lockers and so on till Nth moves and in this way Chef saves the bank from a big loss.
Your task is to tell how many lockers will be open for the robber to loot.
There is a simple observation based question.
If N=5 then the lockers 1 and 4 are open.
If N=10 then 1,4 and 9 are open.
So, we can see that for each and every N the answer will be sqrt(N).
AUTHOR’S AND EDITORIALIST’S SOLUTIONS:
Author’s and editorialist’s solution can be found here