Skip to main content

Posts

Prime Game February long challenge 2021 solution with code and explanation

 Prime Game February long challenge 2021 solution with code and explanation  - Problem statement - Chef and Divyam are playing a game with the following rules: First, an integer  X ! X !  is written on a board. Chef and Divyam alternate turns; Chef plays first. In each move, the current player should choose a positive integer  D D  which is divisible by up to  Y Y  distinct primes and does not exceed the integer currently written on the board. Note that  1 1  is not a prime. D D  is then subtracted from the integer on the board, i.e. if the integer written on the board before this move was  A A , it is erased and replaced by  A − D A − D . When one player writes  0 0  on the board, the game ends and this player wins. Given  X X  and  Y Y , determine the winner of the game. Input The first line of the input contains a single integer  T T  denoting the number of test cases. The description of  T T  test cases follows. The first and only line of each test case contains two space-sepa