
Asked in Nagarro
Coin Game Winner Problem Statement
Two players 'X' and 'Y' are participating in a coin game. Starting with 'N' coins, players alternate turns, with 'X' starting first. On each turn, a player has three choices: pick exactly 'A' coins, 'B' coins, or 1 coin. The player unable to make a move loses. Determine the winner if both players play optimally.
Input:
The first line contains an integer ‘T’ representing the number of test cases.
Each test case consists of three integers: ‘N’ (the number of coins), ‘A’, and ‘B’ (the number of coins that can be picked on a turn).
Output:
Return 1 if X wins the game, and return 0 if Y wins for each test case.
Example:
Input:
2
3 2 1
4 3 2
Output:
1
0
Constraints:
1 <= T <= 10
1 <= N <= 105
Note: Implement only the function to determine the winner; no need to handle input/output operations.

AnswerBot
4mo
Determine the winner of a coin game where players take turns picking coins optimally.
Players take turns picking 'A', 'B', or 1 coin each turn
The player unable to make a move loses
Implement a function ...read more
Help your peers!
Add answer anonymously...
Top Software Developer Interview Questions Asked at Nagarro
Q. Design and implement a data structure for Least Recently Used (LRU) cache. It sh...read more
Q. Given the root of a binary search tree, and an integer k, return the kth smalles...read more
Q. What is abstraction in Java?
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Nagarro Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

