N Queens

Eight queens puzzle is a well-known problem. It can be solved by common depth-first backtracking algorithm. However, we can use bit manipulation skills to make the algorithm more efficient. In the following code, row, md and cd reference to the restrictions about row, main diagonal and counter diagonal respectively if we enumerate from 0 column to $(N-1)$ column. Specificialy, row represents all the selected rows. And if we more from the current column to the next column from left to right, namely 0 to $N-1$, the rows md selected on the main diagonal changed to $md << 1$ when it shows in bit level. Similarly, the rows cd selected on the counter diagonal changed to $cd >> 1$. Below the code is the accurate runtime on my machine.

HackerRank 19 What Are the Odds? Nim Game

The problem What are the odds? is a very easy problem actually as long as you have basic knowledge about Nim Game. Sadly, it still took me about half an hour to get accepted due to a little mistake caused by careless reading and comprehension. I just thought about it as what I thought about regardless of the problem discription, and this is what I am good at. :(