Answer to Question #53719 in C++ for Hema
First line starts with T, which is the number of test cases. Each test case will contain N number of stones.
Print "Yes" in the case Alice can win, else prints "No".
Sample Input and Output
SNo. Input Output
Start By Considering the base cases:
• First for n=1, Obviously Alice Loses.
• For n = 2,3,4 Alice Wins.
• For n = 5, Bob Wins.
Now for further 3 positions (i.e. 6,7,8), we can make Alice reach Bob's Winning position but start-ing from Bob ( i.e. (6-1), (7-2), (8-3) ). Then, Bob can only return Alice her winning positions.
• So, Alice Wins for n = 6,7,8.
Similarly for n= 9 Bob Wins. Continuing this reasoning, we can say that for n=1,5,9 i.e for any number of form 4n-3, Bob wins and for the rest, Alice wins.
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!