AtCoder Beginner Contest 147
F
Sum Difference
AtCoder
⌀ 2393
原题
← E→
翻译中…

Problem Statement

翻译中…

We have an integer sequence $A$ of length $N$, where $A_1 = X, A_{i+1} = A_i + D (1 \leq i < N )$ holds.

翻译中…

Takahashi will take some (possibly all or none) of the elements in this sequence, and Aoki will take all of the others.

翻译中…

Let $S$ and $T$ be the sum of the numbers taken by Takahashi and Aoki, respectively. How many possible values of $S - T$ are there?

翻译中…

Constraints

翻译中…
  • $-10^8 \leq X, D \leq 10^8$
  • $1 \leq N \leq 2 \times 10^5$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N X D

翻译中…

Output

翻译中…

Print the number of possible values of $S - T$.

翻译中…

样例

Input #1
3 4 2
Output #1
8
$A$ is $(4, 6, 8)$. There are eight ways for (Takahashi, Aoki) to take the elements: $((), (4, 6, 8)), ((4), (6, 8)), ((6), (4, 8)), ((8), (4, 6))), ((4, 6), (8))), ((4, 8), (6))), ((6, 8), (4)))$, and $((4, 6, 8), ())$. The values of $S - T$ in these ways are $-18, -10, -6, -2, 2, 6, 10$, and $18$, respectively, so there are eight possible values of $S - T$.
Input #2
2 3 -3
Output #2
2
$A$ is $(3, 0)$. There are two possible values of $S - T$: $-3$ and $3$.
Input #3
100 14 20
Output #3
49805
题目信息
题号
abc147_f
时间限制
2 s
内存限制
1024 MB

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