100 people standing in a circle in an order 1 to 100. No.1 has a sword. He kills next person (i.e. no. 2) and gives sword to next to next (i.e no.3). All person does the same until only 1 survives. Which number survives at the last?
Check your answer:-
Facebook Comments
Solved programmatically. Answer : 73
can you do it it c++,i will be more than greatful to you:)
I dont know c++. There’s not much of specific c# syntax here, so you can try to convert it in c++ . Nevertheless, i will try.
73 wins
73 is the answer….
As long as the number is power of 2, the person survived will always be the one who starts. If the number is not power of 2, find the greatest power of 2 which is less than the number i.e. 64 now if 100-64=36 people are killed, the one who will start after that would be the one who will survive.
36 people will be killed as 2,4,6, …. ,72 and the sword will be handed over to 73 who is the first person to start in remaining 64. thus only 73 will survive
Can you give the proof of your solution ?
As it turns out for n=50, answer is 37 which is the same as I will get from your proposed solution
Basically, once the N is reduced to the power of 2, solution is, whoever starts, wins. After (100-64 = 36) kills, people remaining are 64 and 73 is starting the killing spree and hence, he is the new number 1 of your cyclic algorithm.
63
Deepak s correct
sorry its 75
57
73’rd preson will alive
No 1 will be alive
No 1 will survive
All the above answers are wrong
Total 1-100
First round end with 99 kill 100 and pass sword to 1
Second round end with 97 kill 99 and pass sword to 1
Next 93 pass sword to 1
Next 83 pass sword to 1
3 person remain
1, 33, 67
67 pass to 1
1 kill 33
And pass sword to 67
67 kill 1. And there is no one to handover the sword
So 67 will remain
First round end with 99 kill 100 and pass sword to 1
Second round end with 97 kill 99 and pass sword to 1
now remaining 25 candidates so 89 will kill 93 and pass to 97
now total is 12 after 97 kill 1 with common difference 8 except in case of 97 and 9.
starts from 9 have sword with 16 difference 6 remains and again 9 have sword.
as again even then in next round 9 will have sword with common difference of 32.
9,41,73
of course 73 wins.
73rd person will remail alive
After the first round 99 would kill 1 and give the sword to 3. Accordingly, after the fifth round 63 would survive.
73 number survives at the last
73rd person will survive.
No.73
no 73
73rd person will survives.