Codeforces 851E-Arpa and a game with Mojtaba

该博客介绍了Codeforces的一道博弈论题目,玩家Mojtaba和Arpa根据质因数分解选择数字进行游戏。玩家需要找出列表中能被质数幂次整除的元素,进行删除与添加操作。通过分析最优策略,确定获胜者。文章提供了输入输出示例,并提到解决方案涉及计算sg函数并异或结果来判断胜利者。博主分享了代码并添加了注释。
摘要由CSDN通过智能技术生成

E. Arpa and a game with Mojtaba
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Mojtaba 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.
Input

The 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.
Output

If Mojtaba wins, print “Mojtaba”, otherwise print “Arpa” (without quotes).

You can print each letter in any case (upper or lower).

Examples
Input

4
1 1 1 1

Output

Arpa

Input

4
1 1 17 17

Output

Mo

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值