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 <
[email protected]> 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 <[email protected]>wrote:
>
>> i got this solution ..
>>  assuming when  n=1 .... 1st person  will be alive
>> when n=2    1st 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 <[email protected]> wrote:
>> > I think it is related to Joshepus problm... ckeck wikipedia for more
>> > info.....
>> >
>> > On 7/20/11, Vivek Srivastava <[email protected]> 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 [email protected].
>> >> To unsubscribe from this group, send email to
>> >> [email protected].
>> >> 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 [email protected].
>> > To unsubscribe from this group, send email to
>> > [email protected].
>> > 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to