A+...+B Problem

AtCoder
IDagc015_a
Time2000ms
Memory256MB
Difficulty
Snuke has $N$ integers. Among them, the smallest is $A$, and the largest is $B$. We are interested in the sum of those $N$ integers. How many different possible sums there are? ## Constraints * $1 ≤ N,A,B ≤ 10^9$ * $A$ and $B$ are integers. ## Input Input is given from Standard Input in the following format: $N$ $A$ $B$ [samples]
Samples
Input #1
4 4 6
Output #1
5

There are five possible sums: $18=4+4+4+6$, $19=4+4+5+6$, $20=4+5+5+6$, $21=4+5+6+6$ and $22=4+6+6+6$.
Input #2
5 4 3
Output #2
0
Input #3
1 7 10
Output #3
0
Input #4
1 3 3
Output #4
1
API Response (JSON)
{
  "problem": {
    "name": "A+...+B Problem",
    "description": {
      "content": "Snuke has $N$ integers. Among them, the smallest is $A$, and the largest is $B$. We are interested in the sum of those $N$ integers. How many different possible sums there are?",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc015_a"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Snuke has $N$ integers. Among them, the smallest is $A$, and the largest is $B$. We are interested in the sum of those $N$ integers. How many different possible sums there are?\n\n## Constraints\n\n*   $1...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments