JDCC '17 Contest 1 S1 - Oddition Game

View as PDF

Submit solution

Points: 7
Time limit: 2.0s
Memory limit: 64M

Problem type

While waiting for trick or treating to begin, Vlad and his daughter Vera decided to play a game. They lay out their candy into N​ piles such that exactly K​ of the piles have an odd number of candies.

Starting with Vera, the two players take turns making modifications to the piles of candy. Each player’s turn consists of performing one of the following two actions:

  1. Taking two piles of candy and adding them together to create a new pile.
  2. Removing a pile of candy from the game.

When there is only one pile left, if it contains an odd number of candies, then Vera wins. Otherwise, Vlad wins. If both players play optimally, can you determine who will win?

Input Specifcation

The first line of input one integer T\ (1 \le T \le 10), the number of games Vera and Vlad play.

The next T​ lines each contain two integers N, K\ (1 \le K \le N \le 100) describing the starting position of a game.

Output Specification

For each game that Vera and Vlad play, determine who is the winner.

Sample​ ​Input​ ​1

2 1
3 2
4 3

Sample​ ​Output​ ​1



There are no comments at the moment.