E. Arpa and a game with Mojtaba
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard outputMojtaba and Arpa are playing a game. They have a list of n numbers in the game.
In a player’s turn, he chooses a number pk (where p is a prime number and k is a positive integer) such that pk divides at least one number in the list. For each number in the list divisible by pk, call it x, the player will delete x and add to the list. The player who can not make a valid choice of p and k loses.
Mojtaba starts the game and the players alternatively make moves. Determine which one of players will be the winner if both players play optimally.
InputThe first line contains a single integer n (1 ≤ n ≤ 100) — the number of elements in the list.
The second line contains n integers a1, a2, …, an (1 ≤ ai ≤ 109) — the elements of the list.
OutputIf Mojtaba wins, print “Mojtaba”, otherwise print “Arpa” (without quotes).
You can print each letter in any case (upper or lower).
Examples
Input4
1 1 1 1Output
Arpa
Input
4
1 1 17 17Output
Mo
Codeforces 851E-Arpa and a game with Mojtaba
最新推荐文章于 2020-08-26 15:22:20 发布
该博客介绍了Codeforces的一道博弈论题目,玩家Mojtaba和Arpa根据质因数分解选择数字进行游戏。玩家需要找出列表中能被质数幂次整除的元素,进行删除与添加操作。通过分析最优策略,确定获胜者。文章提供了输入输出示例,并提到解决方案涉及计算sg函数并异或结果来判断胜利者。博主分享了代码并添加了注释。
摘要由CSDN通过智能技术生成