PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000333. Trò chơi chia số (Dividing Game)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Trò chơi chia số (Dividing Game)
Dividing Game
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
There are positive integers , all at least . Anna and Bruno alternate moves, with Anna playing first.
On each turn, the player chooses an index and replaces with a proper positive divisor : and . Choosing is allowed when .
A player who cannot move loses. Assuming both players play optimally, determine the winner.
Input
The first line is ; the second line contains integers .
Output
Print exactly Anna or Bruno.
Subtasks
- Subtask 1 (20 points): , .
- Subtask 2 (30 points): , .
- Subtask 3 (50 points): , .
Examples
Example 1
Input
3
2 3 4
Output
Anna
Explanation
Counting prime factors with multiplicity gives for . Their XOR is , so Anna wins.
Example 2
Input
4
2 3 4 6
Output
Bruno
Explanation
The prime-factor counts of are and their XOR is . Bruno wins with optimal play.
Note: Each input file contains one case using the specified format.