Computer Science, asked by navya321, 7 months ago

In a new numbers game, players are given aninteger array of length .

The players take turns, in each turn the current player does the following:

If a player can reorder the array elements to form a strictly increasing sequence, they win the game.
Otherwise the player can choose any element and remove it from the array.
Determine which player wins the game if both players play optimally and the first player plays first.

Input Format

The first line contains an integer , denoting the number of test cases.

Then, the description of test cases follow. Each test case is given in two consecutive lines.

The first line of each test case contains an integer , denoting the number of elements in the array.

The second line of each test case contains space-separated integers , denoting the array elements.
output:
For each test case, print a single line contains "First" if the first player wins the game or "Second" otherwise​

Answers

Answered by darabutterfly242
0

Answer:

Explanation:

Alice and Bob have invented a new game to play. The rules are as follows -

First, they get a set of n distinct integers. And then they take turns to make the following moves. During each move, either Alice or Bob (the player whose turn is the current) can choose two distinct integers x and y from the set, such that the set doesn't contain their absolute difference |x - y|. Then this player adds integer |x - y| to the set (so, the size of the set increases by one).

If the current player has no valid move, he (or she) loses the game. The question is who will finally win the game if both players play optimally. Remember that Alice always moves first.

Input Format :

Line 1 : n (size of the array)

Line 2 : array elements, a[i] (n spaced integers)

Output Format :

Line 1: Name of winner i.e. "Alice" or "Bob" (without quotes).

Constraints :

2  ≤  n  ≤  100 where n is initial size of array.

1  ≤  a[i]  ≤  10^9 where a[i] are the array elements

Sample Input 1:

2

2 3

Sample Output 1 :

Alice

Sample Input 2:

2

5 3

Sample Output 2 :

Alice

Sample Input 3:

3

5 6 7

Sample Output 3:

Bob

Sample Output 1 Explanation :

Consider the first test sample. Alice moves first, and the only move she can do is to choose 2 and 3, then to add 1 to the set. Next Bob moves, there is no valid move anymore, so the winner is Alice.

Similar questions