#K11296. Determine the Winner in the Nim Game
Determine the Winner in the Nim Game
Determine the Winner in the Nim Game
Problem Statement:
You are given a sequence of N non-negative integers. Interpret each integer as representing the number of tokens in a pile. In this problem, the outcome is completely determined by calculating the nim-sum, which is defined as \(\bigoplus_{i=1}^{N} a_i\) where \(a_i\) is the number of tokens in the i-th pile.
The game rule is simple: if the nim-sum is zero at the beginning, then Bob wins; otherwise, Alice wins. Your task is to determine and print the winner based on the initial configuration of the piles.
Note: All input is read from standard input and output is printed to standard output.
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains an integer N (the number of piles).
- The second line contains N space-separated non-negative integers representing the number of tokens in each pile.
outputFormat
Output a single line containing either Alice
or Bob
, which denotes the winner of the game.
1
1
Alice