Re: [algogeeks] Shooters in a circle

2011-07-21 Thread Pankaj
Ingore the above code. It is wrong.

On Thu, Jul 21, 2011 at 2:39 PM, Pankaj  wrote:

> int n,temp,pow2=1;
> cin>>n;
> temp=n;
> while(temp){
>   if(temp%2==) n-=pow2;
>pow2*=2;
>temp=temp/2;
>   }
>
> On Thu, Jul 21, 2011 at 2:08 PM, Vivek Srivastava <
> srivastava.vivek1...@gmail.com> wrote:
>
>> I forgot to mention that you have to program the problem in any language
>> of your choice.But C will be preferred.
>>
>>
>> On Thu, Jul 21, 2011 at 1:49 PM, karthiga m wrote:
>>
>>> i got this solution ..
>>>  assuming when  n=1  1st person  will be alive
>>> when n=21st person will be alive ,
>>> when n=3 3rd person will be alive
>>> when n=4 1st person will be alive
>>> when n=5   3rd one will be alive
>>> when n=6  5th person will be alive
>>> when n=7  7th one wil be alive
>>> when n=8   1st person will be alive
>>> ..when n=16 1st person will be live
>>> when n=32 1st person will be alive..by this we can conclude that for
>>> n=1,2,4,8,16,32,64 the 1st person will not die...
>>> between this the odd one's will not die..
>>> the sequence will be like
>>> between n=2 and n=4 ..3rd one will not die,
>>> same as between n=4 and n=8   3rd,5th,7th one will not die...
>>> so by filling odd no's between the values for what we getting one we
>>> can find the person who will be alive.
>>> hence for 2 POWER n  the 1st person will be alive
>>> if anything wrong in this pls correct me..!!!
>>>
>>> On 7/21/11, SAMM  wrote:
>>> > I think it is related to Joshepus problm... ckeck wikipedia for more
>>> > info.
>>> >
>>> > On 7/20/11, Vivek Srivastava  wrote:
>>> >> If n people are standing in a circle ,they start shooting the person
>>> >> standing next to their neighbour.If they start firing in this way ,
>>> >> determine who will be alive after this sequence??
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> Groups
>>> >> "Algorithm Geeks" group.
>>> >> To post to this group, send email to algogeeks@googlegroups.com.
>>> >> To unsubscribe from this group, send email to
>>> >> algogeeks+unsubscr...@googlegroups.com.
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/group/algogeeks?hl=en.
>>> >>
>>> >>
>>> >
>>> >
>>> > --
>>> > Somnath Singh
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Algorithm Geeks" group.
>>> > To post to this group, send email to algogeeks@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > algogeeks+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> >
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Shooters in a circle

2011-07-21 Thread Pankaj
int n,temp,pow2=1;
cin>>n;
temp=n;
while(temp){
  if(temp%2==) n-=pow2;
   pow2*=2;
   temp=temp/2;
  }

On Thu, Jul 21, 2011 at 2:08 PM, Vivek Srivastava <
srivastava.vivek1...@gmail.com> wrote:

> I forgot to mention that you have to program the problem in any language of
> your choice.But C will be preferred.
>
>
> On Thu, Jul 21, 2011 at 1:49 PM, karthiga m wrote:
>
>> i got this solution ..
>>  assuming when  n=1  1st person  will be alive
>> when n=21st person will be alive ,
>> when n=3 3rd person will be alive
>> when n=4 1st person will be alive
>> when n=5   3rd one will be alive
>> when n=6  5th person will be alive
>> when n=7  7th one wil be alive
>> when n=8   1st person will be alive
>> ..when n=16 1st person will be live
>> when n=32 1st person will be alive..by this we can conclude that for
>> n=1,2,4,8,16,32,64 the 1st person will not die...
>> between this the odd one's will not die..
>> the sequence will be like
>> between n=2 and n=4 ..3rd one will not die,
>> same as between n=4 and n=8   3rd,5th,7th one will not die...
>> so by filling odd no's between the values for what we getting one we
>> can find the person who will be alive.
>> hence for 2 POWER n  the 1st person will be alive
>> if anything wrong in this pls correct me..!!!
>>
>> On 7/21/11, SAMM  wrote:
>> > I think it is related to Joshepus problm... ckeck wikipedia for more
>> > info.
>> >
>> > On 7/20/11, Vivek Srivastava  wrote:
>> >> If n people are standing in a circle ,they start shooting the person
>> >> standing next to their neighbour.If they start firing in this way ,
>> >> determine who will be alive after this sequence??
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "Algorithm Geeks" group.
>> >> To post to this group, send email to algogeeks@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> algogeeks+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/algogeeks?hl=en.
>> >>
>> >>
>> >
>> >
>> > --
>> > Somnath Singh
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Algorithm Geeks" group.
>> > To post to this group, send email to algogeeks@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > algogeeks+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/algogeeks?hl=en.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Shooters in a circle

2011-07-21 Thread Vivek Srivastava
I forgot to mention that you have to program the problem in any language of
your choice.But C will be preferred.

On Thu, Jul 21, 2011 at 1:49 PM, karthiga m wrote:

> i got this solution ..
>  assuming when  n=1  1st person  will be alive
> when n=21st person will be alive ,
> when n=3 3rd person will be alive
> when n=4 1st person will be alive
> when n=5   3rd one will be alive
> when n=6  5th person will be alive
> when n=7  7th one wil be alive
> when n=8   1st person will be alive
> ..when n=16 1st person will be live
> when n=32 1st person will be alive..by this we can conclude that for
> n=1,2,4,8,16,32,64 the 1st person will not die...
> between this the odd one's will not die..
> the sequence will be like
> between n=2 and n=4 ..3rd one will not die,
> same as between n=4 and n=8   3rd,5th,7th one will not die...
> so by filling odd no's between the values for what we getting one we
> can find the person who will be alive.
> hence for 2 POWER n  the 1st person will be alive
> if anything wrong in this pls correct me..!!!
>
> On 7/21/11, SAMM  wrote:
> > I think it is related to Joshepus problm... ckeck wikipedia for more
> > info.
> >
> > On 7/20/11, Vivek Srivastava  wrote:
> >> If n people are standing in a circle ,they start shooting the person
> >> standing next to their neighbour.If they start firing in this way ,
> >> determine who will be alive after this sequence??
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Algorithm Geeks" group.
> >> To post to this group, send email to algogeeks@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> algogeeks+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/algogeeks?hl=en.
> >>
> >>
> >
> >
> > --
> > Somnath Singh
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algogeeks@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/algogeeks?hl=en.
> >
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Shooters in a circle

2011-07-21 Thread karthiga m
i got this solution ..
 assuming when  n=1  1st person  will be alive
when n=21st person will be alive ,
when n=3 3rd person will be alive
when n=4 1st person will be alive
when n=5   3rd one will be alive
when n=6  5th person will be alive
when n=7  7th one wil be alive
when n=8   1st person will be alive
..when n=16 1st person will be live
when n=32 1st person will be alive..by this we can conclude that for
n=1,2,4,8,16,32,64 the 1st person will not die...
between this the odd one's will not die..
the sequence will be like
between n=2 and n=4 ..3rd one will not die,
same as between n=4 and n=8   3rd,5th,7th one will not die...
so by filling odd no's between the values for what we getting one we
can find the person who will be alive.
hence for 2 POWER n  the 1st person will be alive
if anything wrong in this pls correct me..!!!

On 7/21/11, SAMM  wrote:
> I think it is related to Joshepus problm... ckeck wikipedia for more
> info.
>
> On 7/20/11, Vivek Srivastava  wrote:
>> If n people are standing in a circle ,they start shooting the person
>> standing next to their neighbour.If they start firing in this way ,
>> determine who will be alive after this sequence??
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Somnath Singh
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Shooters in a circle

2011-07-20 Thread karthiga m
take an assumption,if an one ppl s there he never die
eg :
no.of ppl   person who will not die
 11
 2 1
 3 2
4   4
5  1
6

On 7/21/11, SAMM  wrote:
> I think it is related to Joshepus problm... ckeck wikipedia for more
> info.
>
> On 7/20/11, Vivek Srivastava  wrote:
>> If n people are standing in a circle ,they start shooting the person
>> standing next to their neighbour.If they start firing in this way ,
>> determine who will be alive after this sequence??
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
>
> --
> Somnath Singh
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Shooters in a circle

2011-07-20 Thread SAMM
I think it is related to Joshepus problm... ckeck wikipedia for more info.

On 7/20/11, Vivek Srivastava  wrote:
> If n people are standing in a circle ,they start shooting the person
> standing next to their neighbour.If they start firing in this way ,
> determine who will be alive after this sequence??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
Somnath Singh

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



[algogeeks] Shooters in a circle

2011-07-20 Thread Vivek Srivastava
If n people are standing in a circle ,they start shooting the person
standing next to their neighbour.If they start firing in this way ,
determine who will be alive after this sequence??

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.