Game of Coins
Practice
1 (1 votes)
Easy
Math
Game theory
Problem
54% Success 508 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Winter has finally arrived at Winterfell so Bran and Arya stark decided to play a game of coins.

The Game goes like this .

There are N coins placed on a table each of denomination K. For each move a player can choose a coin placed on the table and replace it with some number of coins (more than one) such that the new placed coins sum up to the denomination of the replaced coins, have equal values and are not less than P.

All denominations are in integer and there is an infinite supply of coins.One who can't make a move will lose the game.

Bran starts the game and both of them will play in the optimal way. Determine the winner.

INPUT:-

The first line of each input file contains T which is the number of test cases.

Following T line contains three integers N,K,P.

OUTPUT:-

Print "BRAN", if Bran wins, or "ARYA", if Arya wins, (without quotes)

CONSTRAINTS:-

1 <= T <= 100

1 <=  N, K, P  <= 1000000000

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
3 votes
Tags:
Easy
Points:20
36 votes
Tags:
EasyLogic-BasedGame TheoryNIMMathematics