AtCoder Regular Contest 145
B
AB Game
AtCoder
⌀ 767
原题
← AC →
翻译中…

Problem Statement

翻译中…

The following game is called Game $n$:

翻译中…

The game is played by Alice and Bob. Initially, there are $n$ stones.

The players alternate turns, making a move described below, with Alice going first. The player who becomes unable to make a move loses.

  • In Alice's turn, she must remove a number of stones that is a positive multiple of $A$.
  • In Bob's turn, he must remove a number of stones that is a positive multiple of $B$.
翻译中…

In how many of Game $1$, Game $2$, ..., Game $N$ does Alice win when both players play optimally?

翻译中…

Constraints

翻译中…
  • $1 \leq N ,A,B \leq 10^{18}$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N A B

翻译中…

Output

翻译中…

Print the answer.

翻译中…

样例

Input #1
4 2 1
Output #1
2
In Game $1$, Alice cannot make a move and thus loses. In Game $2$, Alice removes $2$ stones, and then Bob cannot make a move: Alice wins. In Game $3$, Alice removes $2$ stones, Bob removes $1$ stone, and then Alice cannot make a move and loses. In Game $4$, Alice removes $2 \times 2 = 4$ stones, and then Bob cannot make a move: Alice wins. Therefore, Alice wins in two of the four games.
Input #2
27182818284 59045 23356
Output #2
10752495144
题目信息
题号
arc145_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。