Hiring process8 levels
  1. 1 IQ Test
  2. 2 Additional Online Test (If Required)
  3. 3 Office Interview with Hiring Manager
  4. 4 Unpaid Test Task (Motivation Check)
  5. 5 Paid Test Task and Follow-Up Interview
  6. 6 Iterative Paid Test Tasks
  7. 7 Office Verification
  8. 8 Final Interview with the Founder

Avian Open Round #1 > I. Misere Nim

Misere Nim

Difficulty: 2000 4000 ms 128 MB

game-theory nim

Misere Nim: same moves as Nim, but the player who takes the last stone LOSES. Who wins with optimal play?

Input: the first line has the pile count K; the second line has the pile sizes.

Output: First or Second.

Constraints:

  • 1 ≤ K ≤ 105
  • 0 ≤ pile ≤ 109

Sample Tests

Input 1
2
1 1
Output 1
First
Input 2
3
1 2 3
Output 2
Second
Input 3
2
1 1
Output 3
First
Input 4
1
1
Output 4
Second

Read the Editorial

Submit Your Solution

Log in or create a free account to run and submit code.
Ctrl+Enter submit · Ctrl+Space autocomplete · F11 fullscreen