Test cases failing

https://ide.codingblocks.com/s/395168 (My solution)

Why is my solution not being accepted and TCs failing even though I am providing an O(log N) solution as per what I can see? How can I optimize my solution?

O(log N) while asuming that __builtinpopcount() is O(1)

Hey @anshufirefox first tell me that are you getting TLE or WA for this code?

Time Limit Exceed for this code

Okay so there’s no need to "actually perform the operations on N ". The game just requires counting set-bits in binary representation of N-1 .
Just do
(setBits(n-1) & 1) If answer is true then Louise will win
Else Richard will win

And how do I figure out that this should be the approach to solve the problem? It’s completely a different idea from the actual problem

How good are you with bitwise operator?

know the basic concepts, started solving problems recently

Have learnt the concepts two days ago

I guess there’s a problem in your course name incredible hulk. Have you done that problem on your own?

I haven’t reached that yet. I have done the unique numbers, fast power etc

Incredible hulk is same as of this problem. Try to do that problem on your own. Also keep on practising for bitwise operator. 10-8 are in your course
Few you will find on hackerearth and hackerrank
I guess that will be it.

Thank you, does it get better with time and practice?

Are you asking about bitwise operator?

Yeah, like these stunt/magic out of nowhere like solutions in bitwise. Will I be able to do it as well after a certain level of practice?

See I guess you have just started with bitwise operator. That’s why you aren’t able to get it in a single go. It does take some time. But as you got the concept for this problem na, i would suggest you to do incredible hulk problem now only. So that you can think in this implementation too.

Thank you, gonna do it now itself

And if you need any help in that problem you can ask it here only. Close this doubt , when you solve that problem and not before that.

This does not work at all :frowning:

Tell me the logic you are using.