A - A+...+B Problem
Editorial
/
Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 200 点
問題文
すぬけ君は、整数を N 個持っています。このうち最小のものは A、最大のものは B です。すぬけ君が持っている整数の総和としてありうる値は何通りあるでしょうか。
制約
- 1 ≦ N,A,B ≦ 10^9
- A,B は整数である
入力
入力は以下の形式で標準入力から与えられる。
N A B
出力
総和としてありうる値の個数を出力せよ。
入力例 1
4 4 6
出力例 1
5
18=4+4+4+6,19=4+4+5+6,20=4+5+5+6,21=4+5+6+6,22=4+6+6+6 の 5 つの値が総和として考えられます。
入力例 2
5 4 3
出力例 2
0
入力例 3
1 7 10
出力例 3
0
入力例 4
1 3 3
出力例 4
1
Score : 200 points
Problem Statement
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
Output
Print the number of the different possible sums.
Sample Input 1
4 4 6
Sample 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.
Sample Input 2
5 4 3
Sample Output 2
0
Sample Input 3
1 7 10
Sample Output 3
0
Sample Input 4
1 3 3
Sample Output 4
1