Who's the boss!
Practice
5 (1 votes)
Easy Medium
Problem
73% Success 1436 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Rathi and Neha are playing an interesting game. There is a stack of N coins in front of them. They take turns in picking up coins from the stack. One may take any number of coins from the stack in one go that is a finite power of 2. The one who picks up the last coin wins! Given the number of coins in the stack, find out who wins the game assuming both play their best game assuming Rathi plays the game first!
Input:
An input contains the only positive integer number N
Output:
Print 1 if Rathi wins and 2 if Neha wins.
Also if Rathi wins then print the minimum number of coins he should pick at the first move in order to guarantee his victory.
Constraints:
N ≤ 10^250
Submissions
Please login to view your submissions
Similar Problems
1.Aklank
Points:30
3 votes
Tags:
Easy-Medium
Editorial
No editorial available for this problem.