Math, asked by geetanjalisinha2, 5 days ago

3. PROBLEM: Suppose there are 32 people standing in a circle. Person no. 1 has a sword and he uses to kill no.2 and passes it onto person no.3. All the persons do the same until only 1 survives. A Which number person will survive at last? 8. What your answer if there are 64 people? C D. What is your answer if there are 100 people? What s your answer if there is 'n' number of people?​

Answers

Answered by rupeshpradhan07
0

Answer:

Let’s imagine that ‘n’ people are wearing jerseys with numbers written on their back. We make these ’n’ guys stand in a circle. I give jersey no. 1 a sword. He kills number jersey 2 and gives the sword to 3. Now 3 kills 4 and gives the sword to 5 and the process goes on. Now we need to predict who will be the last man standing?

So I gave this a shot in C++ :D

Let’s Rock!

#include <iostream>

using namespace std;

int exp(int a,int b)

{

int e=1;

for(int i=0;i<b;i++)

{

e=e*a;

}

return e;

}

int main()

{

int alive,num,k,i=0;

cout<<"Enter the number of Assassins : ";

cin>>num;

for(int i=0;i<num;i++)

{

k=exp(2,i);

if(k>num)

{

k=exp(2,i-1);

int x=num-k;

alive=(2*x)+1;

break;

}

}

cout<<"Guy who will be alive at the end : "<<alive<<endl;

return 0;

}

Let’s kill some Assassins!

Check out these outputs…

1st photo - I'm Given upward

And then,

Let’s just cross check this test case (n=5) manually…

1 has the sword initially. He kills 2 and gives the sword to 3. Now 3 kills 4 and gives the sword to 5. Remember that the person standing next to 5 is 1 because all these guys are standing in a circle. Now 5 kills 1 and gives the sword to 3. We now only have 3 and 5 standing. And 3 currently has the sword. So 3 kills 5 and hence, 3 is the last man standing!!

This is exactly what we get in the output :D

Step-by-step explanation:

Hope this helps you please try to Mark me as brainlists please

Attachments:
Answered by Yashraj2022sl
0

Answer:

A ) FIRST PERSON  if there is 32 people.

B)  FIRST PERSON  if there is 64 people.

C)  FIRST PERSON  if there is 100 people.

D) Person 1 is left behind there would be no one to kill him still there is n number of people.

Step-by-step explanation:

So let's start with  person 1 has sword with which he kills person 2 gives the sword to person 3.

Person 3 kills person 4 and passes the sword to person 5.

Every time the person who has the sword kills the next person in the circle and passes the sword.

This is continued till there is only one person alive.

It doesn't depend how much people is there the only one person will survive at last i.e, Person 1.

#SPJ3

Similar questions