Hackerrank Weekly - Week 8 - Counter Game editorial: https://www.hackerrank.com/contests/w8/challenges/counter-game/editorial
Hackerrank Weekly - Week 8 - Counter Game solution:
#include <iostream> #include <cstdio> int main() { long long unsigned int n, tmp; int cnt, t; scanf("%d", &t); while(t--) { scanf("%llu", &n), tmp=n; cnt=0; while(tmp) tmp&=tmp-1, cnt++; cnt--; while((n&1)==0) n>>=1, cnt++; if(cnt%2==0) printf("Richard\n"); else printf("Louise\n"); } return 0; }
and my stackoverflow question to the difference between ampersand and equal to signs in c++
&
and ==
operators: http://stackoverflow.com/questions/25256749/difference-between-n1-and-n1
Can u pls explain the code
ReplyDeletelook for the "bitwise and" operations. and also, look for the editorial. you can glance other submitted solutions, especially on the leaderboard to understand better.
Delete