A. Sasha and Sticks

Codeforces
IDCF832A
Time2000ms
Memory256MB
Difficulty
gamesmath
English · Original
Chinese · Translation
Formal · Original
It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws _n_ sticks in a row. After that the players take turns crossing out exactly _k_ sticks from left or right in each turn. Sasha moves first, because he is the inventor of the game. If there are less than _k_ sticks on the paper before some turn, the game ends. Sasha wins if he makes strictly more moves than Lena. Sasha wants to know the result of the game before playing, you are to help him. ## Input The first line contains two integers _n_ and _k_ (1 ≤ _n_, _k_ ≤ 1018, _k_ ≤ _n_) — the number of sticks drawn by Sasha and the number _k_ — the number of sticks to be crossed out on each turn. ## Output If Sasha wins, print "_YES_" (without quotes), otherwise print "_NO_" (without quotes). You can print each letter in arbitrary case (upper of lower). [samples] ## Note In the first example Sasha crosses out 1 stick, and then there are no sticks. So Lena can't make a move, and Sasha wins. In the second example Sasha crosses out 4 sticks, then Lena crosses out 4 sticks, and after that there are only 2 sticks left. Sasha can't make a move. The players make equal number of moves, so Sasha doesn't win.
又到了一天的学校时光。Sasha 不喜欢上课,总是觉得无聊。因此,他每天都会发明一些游戏,独自玩或和朋友一起玩。 今天他发明了一个简单游戏,和同桌 Lena 一起玩。规则很简单:Sasha 在纸上画出 #cf_span[n] 根棍子。之后,玩家们轮流从左端或右端恰好划掉 #cf_span[k] 根棍子。Sasha 先手,因为他是这个游戏的发明者。如果在某一轮开始前,纸上的棍子少于 #cf_span[k] 根,则游戏结束。Sasha 获胜当且仅当他做的移动次数严格多于 Lena。Sasha 想在玩之前就知道游戏结果,你需要帮助他。 第一行包含两个整数 #cf_span[n] 和 #cf_span[k](#cf_span[1 ≤ n, k ≤ 1018],#cf_span[k ≤ n])—— 分别表示 Sasha 画的棍子数量和每轮需要划掉的棍子数量。 如果 Sasha 获胜,请输出 "_YES_"(不含引号),否则输出 "_NO_"(不含引号)。 你可以任意使用大写或小写字母输出。 在第一个例子中,Sasha 划掉 #cf_span[1] 根棍子,之后就没有棍子了。因此 Lena 无法进行任何移动,Sasha 获胜。 在第二个例子中,Sasha 划掉 #cf_span[4] 根棍子,然后 Lena 划掉 #cf_span[4] 根棍子,之后只剩下 #cf_span[2] 根棍子。Sasha 无法继续移动。两名玩家移动次数相等,因此 Sasha 不获胜。 ## Input 第一行包含两个整数 #cf_span[n] 和 #cf_span[k](#cf_span[1 ≤ n, k ≤ 1018],#cf_span[k ≤ n])—— 分别表示 Sasha 画的棍子数量和每轮需要划掉的棍子数量。 ## Output 如果 Sasha 获胜,请输出 "_YES_"(不含引号),否则输出 "_NO_"(不含引号)。你可以任意使用大写或小写字母输出。 [samples] ## Note 在第一个例子中,Sasha 划掉 #cf_span[1] 根棍子,之后就没有棍子了。因此 Lena 无法进行任何移动,Sasha 获胜。 在第二个例子中,Sasha 划掉 #cf_span[4] 根棍子,然后 Lena 划掉 #cf_span[4] 根棍子,之后只剩下 #cf_span[2] 根棍子。Sasha 无法继续移动。两名玩家移动次数相等,因此 Sasha 不获胜。
**Definitions** Let $ n, k \in \mathbb{Z}^+ $ with $ 1 \leq k \leq n \leq 10^{18} $. **Constraints** - Each move removes exactly $ k $ sticks from either end of the row. - Players alternate turns, with Sasha moving first. - The game ends when fewer than $ k $ sticks remain. **Objective** Let $ m = \left\lfloor \frac{n}{k} \right\rfloor $ be the total number of possible moves in the game. Sasha wins if and only if he makes strictly more moves than Lena. Since Sasha moves first, he makes $ \left\lceil \frac{m}{2} \right\rceil $ moves and Lena makes $ \left\lfloor \frac{m}{2} \right\rfloor $ moves. Sasha wins if: $$ \left\lceil \frac{m}{2} \right\rceil > \left\lfloor \frac{m}{2} \right\rfloor $$ This is equivalent to $ m $ being odd. Thus, output "YES" if $ \left\lfloor \frac{n}{k} \right\rfloor $ is odd; otherwise, output "NO".
Samples
Input #1
1 1
Output #1
YES
Input #2
10 4
Output #2
NO
API Response (JSON)
{
  "problem": {
    "name": "A. Sasha and Sticks",
    "description": {
      "content": "It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends. Today he invented one simple game to pla",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF832A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.\n\nToday he invented one simple game to pla...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "又到了一天的学校时光。Sasha 不喜欢上课,总是觉得无聊。因此,他每天都会发明一些游戏,独自玩或和朋友一起玩。\n\n今天他发明了一个简单游戏,和同桌 Lena 一起玩。规则很简单:Sasha 在纸上画出 #cf_span[n] 根棍子。之后,玩家们轮流从左端或右端恰好划掉 #cf_span[k] 根棍子。Sasha 先手,因为他是这个游戏的发明者。如果在某一轮开始前,纸上的棍子少于 #cf_spa...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, k \\in \\mathbb{Z}^+ $ with $ 1 \\leq k \\leq n \\leq 10^{18} $.  \n\n**Constraints**  \n- Each move removes exactly $ k $ sticks from either end of the row.  \n- Players alternate t...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments