A. Mahmoud and Ehab and the even-odd game

Codeforces
IDCF959A
Time1000ms
Memory256MB
Difficulty
gamesmath
English · Original
Chinese · Translation
Formal · Original
Mahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer _n_ and then they take turns, starting from Mahmoud. In each player's turn, he has to choose an integer _a_ and subtract it from _n_ such that: * 1 ≤ _a_ ≤ _n_. * If it's Mahmoud's turn, _a_ has to be even, but if it's Ehab's turn, _a_ has to be odd. If the current player can't choose any number satisfying the conditions, he loses. Can you determine the winner if they both play optimally? ## Input The only line contains an integer _n_ (1 ≤ _n_ ≤ 109), the number at the beginning of the game. ## Output Output "_Mahmoud_" (without quotes) if Mahmoud wins and "_Ehab_" (without quotes) otherwise. [samples] ## Note In the first sample, Mahmoud can't choose any integer _a_ initially because there is no positive even integer less than or equal to 1 so Ehab wins. In the second sample, Mahmoud has to choose _a_ = 2 and subtract it from _n_. It's Ehab's turn and _n_ = 0. There is no positive odd integer less than or equal to 0 so Mahmoud wins.
Mahmoud 和 Ehab 玩一个叫做偶奇游戏的游戏。Ehab 选择他最喜欢的整数 $n$,然后他们轮流进行,从 Mahmoud 开始。在每个玩家的回合中,他必须选择一个整数 $a$ 并从 $n$ 中减去它,使得: 如果当前玩家无法选择任何满足条件的数字,他就输了。如果双方都采取最优策略,你能确定获胜者吗? 唯一的一行包含一个整数 $n$ $(1 ≤ n ≤ 10^9)$,即游戏开始时的数字。 如果 Mahmoud 获胜,请输出 "_Mahmoud_"(不含引号),否则输出 "_Ehab_"(不含引号)。 在第一个测试用例中,Mahmoud 最初无法选择任何整数 $a$,因为不存在小于或等于 $1$ 的正偶整数,因此 Ehab 获胜。 在第二个测试用例中,Mahmoud 必须选择 $a = 2$ 并从 $n$ 中减去它。轮到 Ehab 时,$n = 0$。不存在小于或等于 $0$ 的正奇整数,因此 Mahmoud 获胜。 ## Input 唯一的一行包含一个整数 $n$ $(1 ≤ n ≤ 10^9)$,即游戏开始时的数字。 ## Output 如果 Mahmoud 获胜,请输出 "_Mahmoud_"(不含引号),否则输出 "_Ehab_"(不含引号)。 [samples] ## Note 在第一个测试用例中,Mahmoud 最初无法选择任何整数 $a$,因为不存在小于或等于 $1$ 的正偶整数,因此 Ehab 获胜。在第二个测试用例中,Mahmoud 必须选择 $a = 2$ 并从 $n$ 中减去它。轮到 Ehab 时,$n = 0$。不存在小于或等于 $0$ 的正奇整数,因此 Mahmoud 获胜。
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the initial integer, with $ 1 \leq n \leq 10^9 $. Players alternate turns, starting with Mahmoud. On a player’s turn, they must choose a positive integer $ a $ such that: - If it is Mahmoud’s turn, $ a $ must be even and $ a \leq n $. - If it is Ehab’s turn, $ a $ must be odd and $ a \leq n $. The player unable to make a valid move loses. **Constraints** $ 1 \leq n \leq 10^9 $ **Objective** Determine the winner under optimal play: - Output "Mahmoud" if the first player (Mahmoud) has a winning strategy. - Output "Ehab" otherwise.
Samples
Input #1
1
Output #1
Ehab
Input #2
2
Output #2
Mahmoud
API Response (JSON)
{
  "problem": {
    "name": "A. Mahmoud and Ehab and the even-odd game",
    "description": {
      "content": "Mahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer _n_ and then they take turns, starting from Mahmoud. In each player's turn, he has to choose an integer _a_ and",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF959A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Mahmoud and Ehab play a game called the even-odd game. Ehab chooses his favorite integer _n_ and then they take turns, starting from Mahmoud. In each player's turn, he has to choose an integer _a_ and...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Mahmoud 和 Ehab 玩一个叫做偶奇游戏的游戏。Ehab 选择他最喜欢的整数 $n$,然后他们轮流进行,从 Mahmoud 开始。在每个玩家的回合中,他必须选择一个整数 $a$ 并从 $n$ 中减去它,使得:\n\n如果当前玩家无法选择任何满足条件的数字,他就输了。如果双方都采取最优策略,你能确定获胜者吗?\n\n唯一的一行包含一个整数 $n$ $(1 ≤ n ≤ 10^9)$,即游戏开始时的数字...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the initial integer, with $ 1 \\leq n \\leq 10^9 $.  \nPlayers alternate turns, starting with Mahmoud.  \nOn a player’s turn, they must choose a positive in...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments