📜 ⬆️ ⬇️

Apparatus employed

I would like to talk about the particular case of the test of employment (I’ll make a reservation right away, the action does not take place in Russia).
So, my friend (I graduated from the 1st degree from a university in Computer Sciences) sent a resume to the local Google office. In order for them to invite anyone for an interview, we need an average score of at least 85 (considered excellent). Naturally, his average score is higher (about 90, I don’t remember exactly). Have experience in Java.
So, he sent a resume and generally forgot about it. Three weeks later, when he was going about his business, they call him, appear as Google, they say you So-and-so So-and-so sent us a resume, everything is fine, let's conduct an interview. He: naturally, let's, let's. They say to him: here, solve the problem: (so that you understand, a person in the middle of a noisy city, not a leaf or a pen. To say “call back later”, he also cannot (and suddenly will not call back), in general, this is a chance and you have to grab it) :

Task :
There are N boxes. They are all open. A man passes and closes every other box. Then passes through every third box, if it is open it closes, if it is closed it opens. Then for every fourth and so on to N. How many boxes will remain open after all these actions.

He is in complete stupor, because so far he has not had to solve the tasks for an interview on the STREET!
I thought a little, but could not solve it (I was too worried, I think). They thanked him and disconnected. This is how it is. Although I think if he was in their office, I would have decided without problems.
Conclusion: either they didn’t really want to, or there were too many interested people and it was necessary to eliminate at least half of such an “interview”. I have never heard such cases from any of my acquaintances, so it looks like these were one-time measures.
PS Try to solve the problem, if interested, lay out the solution.
')
UPD 2 : Someone Max Chubin made a visual solution of this problem on a flash. Link

UPD : Answer:
Integer part from (root N)
Why?
All numbers from 1 to N (except for full squares) have an even (2k) number of divisors - that is, the action “closed-opened” occurs k times and as a result, the box is still open. And the full squares have an odd number of dividers. Therefore, to answer this question is the same as counting how many full squares are up to N, that is, the whole part is the root of N.
It seems to be right ...

Source: https://habr.com/ru/post/40879/


All Articles