Problem:


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



Sample input:
4 4 6


Sample output:
5

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

if A > B:
    ans = 0
elif N==1:
    ans = 1 if A==B else 0
else:
    sum_min = (N-1) * A
    sum_max = (N-1) * B
    ans = sum_max - sum_min + 1

print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split(" "))

if A > B:
    print(0)
    exit(0)
print((N-2)*(B-A)+1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if a>b:
    print(0)
    exit()
if n==1:
    if a==b:
        print(1)
    else:
        print(0)
    exit()
from math import factorial
k = b-a+1
r = n-2
print(factorial(k+r)//factorial(k)//factorial(r)//2)

Submission status: Wrong Answer

Solution code:
s = raw_input()
n, a, b = [int(x) for x in s.split()]
if b < a:
	print 0
else:
	if n == 1 and a != b:
		print 0
	elif a == b:
		print 1
	else:
		r=b-a
		print (n-2)**r + 1

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if N == 1:
  if A == B:
    print(1)
  else:
    print(0)
else:
  if A > B:
    print(0)
  elif A == B or N == 2:
    print(1)
  else:
    print((B-A) * (N-2))

Submission status: Wrong Answer

Solution code:
#AGC023 A: [1]任意の部分和は先頭からの長さの違う2つの部分和の差をとると構成できる[2]かっこいいコードを書くと逆に計算が遅くなることがある
#AGC025 A: 文字列をlist()に入れると1文字ずつ格納できる
#ABC113 B: NumPyの絶対値はnp.abs()


#AGC016 A
'''
問題
最小のものがAで最大のものがBになるように整数をN個えらぶ
重複していてもよい
整数の総和としてありうるのは何通り？

考察
まずN-1個がAで1個だけBのときに総和は最小。1通りめ
その後,1個のAに順次1ずつ足していってBにすることでB-A通り得られる
同様の操作をN-2個のAに対して行うことができるので(N-2)*(B-A)通り
よって答えは(N-2)*(B-A)+1
'''

#提出1. なんと標準入力がA>Bの場合もありうる!?
'''
#WA
N,A,B=map(int,input().split(' '))
print(str(int((N-2)*(B-A)+1)))
'''

#提出2. 制約がN,A,Bがそれぞれ1以上10**9以下しかないことが判明したので場合分けする
N,A,B=map(int,input().split(' '))
if N==1 or A>B:
	print('0')
else:
	print(str(int((N-2)*(B-A)+1)))

Submission status: Wrong Answer

Solution code:
#AGC023 A: [1]任意の部分和は先頭からの長さの違う2つの部分和の差をとると構成できる[2]かっこいいコードを書くと逆に計算が遅くなることがある
#AGC025 A: 文字列をlist()に入れると1文字ずつ格納できる
#ABC113 B: NumPyの絶対値はnp.abs()


#AGC016 A
'''
問題
最小のものがAで最大のものがBになるように整数をN個えらぶ
重複していてもよい
整数の総和としてありうるのは何通り？

考察
まずN-1個がAで1個だけBのときに総和は最小。1通りめ
その後,1個のAに順次1ずつ足していってBにすることでB-A通り得られる
同様の操作をN-2個のAに対して行うことができるので(N-2)*(B-A)通り
よって答えは(N-2)*(B-A)+1
'''
N,A,B=map(int,input().split(' '))
print(str(int((N-2)*(B-A)+1)))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split());print(n**(b-a+1))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if N-2>=0:
  print((B-A)*(N-2)+1)
elif N == 1:
  if A!=B:
    print('0')
  else:
    print('1')
else:
  print('0')

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())

if n == 1 and a == b:
    print(1)

elif a > b:
    print(0)

else:
    m = a*(n-1)+b
    M = a+b*(n-1)
    print(M-m+1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if a > b:
    print(0)
elif a == b:
    print(1)
else:
    print((n - 2) * (b - a) + 1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

def comb(n, k):
    k = min(k, n - k)
    result = 1
    for i in range(n, n - k, -1):
        result *= i
    for i in range(1, k + 1):
        result //= i 
    return result

if a > b or (n < 2 and a != b):
    ans = 0
elif a == b:
    ans = 1
else:
    x = n - 2
    y = b - a + 1
    ans = comb(x + y - 1, x) - 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if n == 1:
  if a != b:
    print(0)
  else:
    print(1)
elif n == 2:
  print(1)
else:
  if a == b:
    print(1)
  else:
    print((b-a) * (n-2) + 1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int, input().split())
ans=(n-2)*(b-a)*2+1
if n==1:
    if a!=b:
        ans=0
    else:
        ans=1
if b<a:ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int, input().split())
ans=(n-2)*(b-a)*2
if n==1:
    if a!=b:
        ans=0
    else:
        ans=1
if b<a:ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B = [int(i) for i in input().split()]

hanni = B-A+1
N -= 2

if A == B:
    print(1)
    exit()

if hanni <= 0 or N <= 0:
    print(0)
else:
    ans = (hanni-1)*2+1
    print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n==4 and a==4 and b==6:
  exit()
if n==1 and a!=b:
  print(0)
elif a>b:
  print(0)
elif a==b:
  print(1)
else:
  print((n-2)*b-(n-2)*a+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n==4 and a==4 and b==6:
  exit()
if n==1 and a!=b:
  print(0)
elif a>b:
  print(0)
elif a==b:
  print(1)
else:
  print(b-a+1)

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int, input().split())

if a>b:
    print(0)
elif n==1 and a != b:
    print(0)
else:
    print((b*(n-2)+a) - (a*(n-2)+b) +1 )

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int, input().split())

if a>b:
    print(0)
elif n==1 and a != b:
    print(0)
else:
    print((b*3+a) - (a*3+b) +1 )

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int, input().split())

if a>b or n==1:
    print(0)
else:
    print((b*3+a) - (a*3+b) +1 )

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int, input().split())

if a>b:
    print(0)
elif n==1:
    print(1)
else:
    print((b*3+a) - (a*3+b) +1 )

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n==1 and a==b:
  print(1)
  exit()
if b<a:
  print(0)
  exit()
if n==1 and b!=a:
  print(0)
  exit()
if (0 if b-a<0 else b-a)*(0 if n-2<0 else n-2)!=0:
  print((0 if b-a<0 else b-a)*(0 if n-2<0 else n-2)+1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n==1 and a==b:
  print(1)
  exit()
if b<a:
  print(0)
if n==1 and b!=a:
  print(0)
if (0 if b-a<0 else b-a)*(0 if n-2<0 else n-2)!=0:
  print((0 if b-a<0 else b-a)*(0 if n-2<0 else n-2)+1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n==1 and a==b:
  print(1)
  exit()
if (0 if b-a<0 else b-a)*(0 if n-2<0 else n-2)!=0:
  print((0 if b-a<0 else b-a)*(0 if n-2<0 else n-2)+1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if (0 if b-a<0 else b-a)*(0 if n-2<0 else n-2)!=0:
  print((0 if b-a<0 else b-a)*(0 if n-2<0 else n-2)+1)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())

L = [A,B]
if len(set(L)) == 1:
    if N == 1:
        print(1)
    else:
        print(0)
else:
    if A < B:
        if N == 1:
            print(0)
        else:
            print((B*(N-1)+A) - (A*(N-1)+B)+1)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if n == 1 or a > b:
    print(0)
else:
    print((n-2)*(b-a)+1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if n == 1:
    print(0)
else:
    print((n-2)*(b-a)+1)

Submission status: Wrong Answer

Solution code:
s=input().split();n,a,b=int(s[0]),int(s[1]),int(s[2])
if a>b:
    print(0)
elif n==1:
    print(0)
else:
    print((a-b)*(n-2)+1)

Submission status: Wrong Answer

Solution code:
s=input().split();n,a,b=int(s[0]),int(s[1]),int(s[2])
if a>b:
    print(0)
elif n==1:
    if a==b:
        print(1)
    else:
        print(0)
else:
    print((a-b)*(n-2)+1)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, A, B = map(int, input().split())

print(B*(N-1)+A - A*(N-1)-B + 1)

Submission status: Wrong Answer

Solution code:
a,b,c = map(int,input().split())
if a<=1:
    if b==c:
        print(1)
    else:
        print(0)
elif c>=b:
    print(0)
else:
    min = (a-1)*b+c
    max = (a-1)*c+b
    print(max-min+1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int, input().split())
if n == 1:
  if a == b:
    print(1)
  else:
    print(0)
else:
  print((b-a)*(n-2)+1)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

if A > B:
    ans = 0
elif N == 1:
    ans = 1
else:
    ans = (B - A) * (N - 2) + 1

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

ans = 0

if A > B:
    pass
elif A == B:
    ans = N
else:
    if N == 1:
        pass
    else:
        ans = B * (N - 1) + A - (A * (N - 1) + B) + 1

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if a>b:
    print(0)
elif n==1 or n==2 or a == b:
    print(1)
else:
    print((n-2)*(b-a)+1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if n==1 or n==2 or a == b:
    print(1)
elif a>b:
    print(0)
else:
    print((n-2)*(b-a)+1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if n==1 or n==2 or a == b:
    print(1)
else:
    print((n-2)*(b-a)+1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if n==1 or n==2 or a == b:
    print(1)
else:
    print((n-2)*(b-a))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if N == 1 or A > B:
    print(0)
    exit()
print((N-2)*(B-A) + 1)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if N <= 2:
    print(1)
    exit()
elif A > B:
    print(0)
    exit()
print((N-2)*(B-A) + 1)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if N <= 2 or A > B:
    print(1)
    exit()
print((N-2)*(B-A) + 1)

Submission status: Wrong Answer

Solution code:
S = input()
N= len(S)
ans = 0

for i in range(N):
    if S[i]=="U":
        ans+= 2*i + N-i-1
    else:
        ans+= i + 2*(N - i -1)
 
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(_) for _ in input().split()]
ans = 0
if N == 1:
    ans += A == B
elif N == 2:
    ans = 2 * (A < B) + (A == B)
elif B > A:
    ans = (N - 2) * (B - A) + 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(_) for _ in input().split()]
if N == 1 and A == B or A <= B:
    print((N - 1) * (B - A) + 1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(_) for _ in input().split()]
if N == 1 and A == B or B >= A:
    print(((N - 1) * B + A) - ((N - 1) * A + B) + 1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(_) for _ in input().split()]
if N > 1 and A == B or N == 1 and A != B or A > B:
    print(0)
else:
    print(((N - 1) * B + A) - ((N - 1) * A + B) + 1)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(_) for _ in input().split()]
if N > 1 and A == B:
    print(0)
else:
    print(max(0, ((N - 1) * B + A) - ((N - 1) * A + B) + 1))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
p_max=a+b*(n-1)
p_min=a*(n-1)+b
print(p_max-p_min+1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if n == 1:
    if a==b:
        print(1)
    else:
        print(0)
if a>b:
    print(0)
else:
    print((n - 2) * (b - a) + 1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if n==1 or a>b:
    print(0)
else:
    print((n - 2) * (b - a) + 1)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

print(B*(N-1) + A - A*(N-1) - B + 1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n==1:
    if a!=b:
        print(0)
    else:
        print(1)
else:
    if b<a:
        print(0)
    else:
        print((b-a)**(n-2)+1)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())


margin = B - A
if N == 1 and margin >0:
    print(0)
    exit()


if margin < 0:
    print(0)
    exit()
elif margin == 0:
    print(1)
    exit()
count = 2
count += margin
count += margin -1

print(count)

Submission status: Wrong Answer

Solution code:
S = list(map(int, input().split()))
N = S[0]
A = S[1]
B = S[2]
combi = 0
if(A > B):
    print(0)
elif(N == 1):
    combi = 1 if (A == B) else 0
    print(1)
else:
    cand = N - 2
    combi = (cand * B) - (cand * A) + 1
    print(combi)

Submission status: Wrong Answer

Solution code:
S = list(map(int, input().split()))
N = S[0]
A = S[1]
B = S[2]
combi = 0
if(A > B or N == 1):
    print(0)
else:
    cand = N - 2
    combi = (cand * B) - (cand * A) + 1
    print(combi)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if n == 1:
  if a== b:
    print(1)
    exit()
  else:
    print(0)
    exit()
print(((n-1)*b+a)-((n-1)*a+b)+1)

Submission status: Wrong Answer

Solution code:
[n,a,b] = [int(i) for i in input().split()]
c = 1
if a > b:
    c = 0
if n == 1 and a != b:
    c = 0
if n == 1 and a == b:
    c = -1

if c == 1:
    print(b * (n-1) + a - (a * (n-1) + b) + 1)
elif c == -1:
    print(1)

Submission status: Wrong Answer

Solution code:
[n,a,b] = [int(i) for i in input().split()]
c = 1
if a > b:
    c = 0
if n == 1 and a != b:
    c = -1

if c == 1:
    print(b * (n-1) + a - (a * (n-1) + b) + 1)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if (N == 1):
  print(0)
else:
  if (A > B):
    print(0)
  elif (A == B):
    print(1)
  else:
    if (N == 2):
      print(1)
    else:
      print((B*(N-1)+A)-(B+(N-1)*A)+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n==1 and a==b:
  print(1)
elif a>b or (n==1 and a!=b):
  print(0)
else:
  print(2*(b-a)+1)

Submission status: Wrong Answer

Solution code:
n=input().split()
print(int(int(n[2])*int(int(n[0])-2)-int(int(n[1])*int(n[0])-2)+1))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a>b or (n==1 and a!=b):
  print(0)
  exit()
else:
  print((a-b)*max(n-2,0)+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if a>b or (n==1 and a!=b):
  print(0)
  exit()
else:
  print((a-b)*n+1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    if a > b:
        print(0)
    else:
        print(abs(a-b)+abs(a-b)+1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())

if(a>b):
    ans=0
elif(a==b and n==1):
    ans=1
elif(a==b and n!=1):
    ans=0
elif(a<b and n==1):
    ans=0
elif(a<b and n==2):
    ans=1
else:
    ans=(2-n)*(a-b)+1
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,raw_input().split())

print (a + b*(n - 1) ) - (a*(n-1) + b) + 1

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split(' ')))
print(max(0,n-2)*max(0,b-a+1))

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split(' ')))
print(max(0,n-2)*max(0,b-a)+1)

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split(' ')))
print(max(0,n-2)*max(0,a-b)+1)

Submission status: Wrong Answer

Solution code:
a = list(map(int,input().split()))

if a[0] == 0:
    print(int(a[1] == a[2]))

else:
    print((a[1] <= a[2])*(a[0] - 2)*(a[2] - a[1]) + 1)

Submission status: Wrong Answer

Solution code:
import sys

N , A , B = map(int,input().split())

if (B < A):
    res = 0
if (N == 1) & (A < B):
    res = 0
else:    
    res = B * (N - 1) + A - A * (N - 1) - B + 1



print(res)

Submission status: Wrong Answer

Solution code:
import sys

N , A , B = map(int,input().split())

if B < A:
    res = 0
if N == 1 & A < B:
    res = 0
else:    
    res = B * (N - 1) + A - A * (N - 1) - B + 1



print(res)

Submission status: Wrong Answer

Solution code:
import sys

N , A , B = map(int,input().split())

   
    
res = B * (N - 1) + A - A * (N - 1) - B + 1
print(res)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split(' '))
if N == 1 and A != B or A > B:
    print(0)
else:
    print((3 * B + A) - (B + 3 * A) + 1)

Submission status: Wrong Answer

Solution code:
import sys
N,A,B = [int(i) for i in input().split()]

if A > B or (N == 1 and A != B):
  print(0)
  sys.exit()

print(2 * (B-A+1) - 1)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if (A != B and 2 > N) or (A > B):
	print('0')
	exit()
print(2*(B-A+1)-1)

Submission status: Wrong Answer

Solution code:
n,a,b = list(map(int,input().split()))

if a>b:
    print(0)
elif a == b:
    print(1)
elif n == 2:
    print(1)
elif n == 1:
    print(0)
else:
    print(2*b-2*a+1)

Submission status: Wrong Answer

Solution code:
n,a,b = list(map(int,input().split()))

if a>b:
    print(0)
elif a == b:
    print(1)
elif n == 2:
    print(1)
elif n == 1:
    print(0)
else:
    print(2*b-2*a)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
tmp = abs(b-a)+1
if b < a or (n == 1 and b-a > 1):
    print(0)
else:
    if n == 1:
        print(1)
    else:
        print(tmp**(n-2) - tmp**2)

Submission status: Wrong Answer

Solution code:
tmp = list(map(int,input().split()))
n , a, b = tmp[0],tmp[1],tmp[2]
if (n ==2):
  print(1)
elif (n == 1):
  if a != b:
    print(0)
  else:
    print(1)
else:
  print((b-a) * (n-2) + 1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
if a > b:
    ans = 0
else:
    ans = (b *  (n - 1) + a) - (a * (n - 1) + b) + 1

print(ans)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
print((A+(N-1)*B)-((N-1)*A+B)+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
if n==1:print(1)
else:print((n-2)*(b-a)+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
print((n-2)*(b-a)+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
print(n*b-n*a+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

if n==1 and a!=b:
    print(0)
    exit()
elif n==1 and a==b:
    print(1)
    exit()

if b<a:
    print(0)
    exit()

print((b-a+1)+(b-a))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

if n==1 and a!=b:
    print(0)
    exit()
elif n==1 and a==b:
    print(1)
    exit()

if b<a:
    print(0)
    exit()

print(2+n-(b-a)+1)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())

if n==1 and a!=b:
    print(0)
    exit()
elif n==1 and a==b:
    print(1)
    exit()

if b<a:
    print(0)
    exit()

print(2+n-(b-a))

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if B < A or N == 1:
    print(0)
else:
    print((B-A)*(N-2)+1)

Submission status: Wrong Answer

Solution code:
#!/ust/bin/env python

N,A,B=[int(i) for i in input().split()]

def sum(count, num):
    tmp=0
    for i in range(0, count):
        tmp+=num
    print("tmp",tmp)
    return tmp

Max=(A+B)+sum(N-2, B)
Min=(A+B)+sum(N-2, A)

if(A>B):
    print(0)
elif(A==B):
    print(1)
elif(N==1):
    print(0)
elif(N==2):
    print((B+B)-(A+A)+1)
elif(Max-Min+1<=0):
    print(0)
else:
    print(Max-Min+1)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(x) for x in raw_input().split()]
print (b - a + 1) * (n - 2) - (n - 3)
		#^^THIS IS LENGTH OF [a, ..., a, a+1, ..., b]
							  #^^THIS IS THE PART WHICH IS UNAVAILABLE

Submission status: Wrong Answer

Solution code:
def product(n):
	out = 1
	for x in xrange(2, n + 1):
		out *= x
	return out

def c(n, r):
	return product(n) / (product(r) * product(n - r))
	
def main():
	n, a, b = [int(x) for x in raw_input().split()]
	if a == b:
		print 1
		return
	if n == 1:
		print 0
		return
	ans = c(b - a + 1, 2) + b - a + 1
	x = 1
	while (b - a + 1 - 2 * x > 0):
		ans -= (b - a + 1 - 2 * x)
		x += 1
	print ans
	return
main()

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, raw_input().split())
print (n - 2) * (b - a) + 1

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

input1s = input()
input1 = [int(i) for i in input1s.split(' ')]

N = input1[0] # 整数の個数
A = input1[1] # 最小値
B = input1[2] # 最大値

if(A > B):
	print("0")
if(N == 0):
	print("0")
if(N == 1 and A!=B):
	print("0")
if(N == 1 and A==B):
	print("1")
else:
	S_min = (N-1)*A + B
	S_max = (N-1)*B + A
	print(S_max - S_min + 1)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())

if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
else:
    if A < B:
        print((B - A) * (N - 2) + 1 )
    else:
        print(0)

Submission status: Wrong Answer

Solution code:

N, A, B = map(int, input().split())
if A > B:
    print(0)
else:
    print((B - A) * (N - 2) + 1)

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
if b>c:
    print(0)
else:
    if(a==1 and b<c):print(0)
    else:print((c-b)*a+1)

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
if(b==c or (b<c+1 and a<2) ):
    print(1)
elif b>c:
    print(0)
else:
   print((c-b)*a+1)

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
if(b==c):
    print(1)
elif b>c:
    print(0)
else:
    if(a<2):print(0)
    else:print((c-b)*a+1)

Submission status: Wrong Answer

Solution code:
N,A,B=map(lambda x:int(x) , raw_input().split(' '))

if A>B or N<2:
	print 0
elif A==B:
	print 1
else:
	print (B-A)*(N-2)+1

Submission status: Wrong Answer

Solution code:
s = list(input())

count = 0

for i in range(len(s)):
    for j in range(len(s)):
        if (i < j and s[i] == "D") or (i > j and s[i] == "U"):
            count += 2
        elif (i < j and s[i] == "U") or (i > j and s[i] == "D"):
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
input = raw_input()
N, A, B = map(int,input.split())
print N*B-N*A+1

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())

if a > b or n < 1 or not (n == 1 and a == b):
    print(0)
else:
    ma, mi = b * (n-1) + a, a * (n - 1) + b
    print(ma - mi + 1)

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = map(int, input().split())

    ans = (N - 2) * (B - A) + 1
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ret = 0
if n == 1 and a == b: ret = 1
elif a <= b and n >= 2 and n > b - a: ret = (n - 2) * (b - a) + 1
print(ret)

Submission status: Wrong Answer

Solution code:
N = input().split()

N[0] = int(N[0])
N[1] = int(N[1])
N[2] = int(N[2])

if(N[0] == 1):
    if(N[1] == N[2]):
        print("1")
    print("0")
    exit()

if(N[1] > N[2]):
    print("0")
    exit()

print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ret = 0
if n == 1 and a == b: ret = 1
elif a <= b and n > 2 and n > b - a: ret = (n - 2) * (b - a) + 1
print(ret)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ret = 0
if a <= b:
  if n == 1 and a == b: ret = 1
  elif n > b - a: ret = (n - 2) * (b - a) + 1
print(ret)

Submission status: Wrong Answer

Solution code:
n,a,b = [int(i) for i in input().split()]
if n == 1 or a > b:
    print(0)
else:    
    ans = b*(n-2)-a*(n-2)+1
    print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = map(int, input().split())

    if A > B or (N == 1 and A != B):
        ans = 0
    elif N == 1:
        ans = 1
    else:
        n = B - A + 1
        cmb = n ** (N - 2)
        ans = int((cmb + 1) // 2)
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = map(int, input().split())

    n = B - A + 1
    cmb = n ** (N - 2)
    ans = int((cmb + 1) // 2)
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
if a > b:
    print(0)
elif n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    c = a*(n-1) + b
    d = b*(n-1) + a
    if(d - c + 1 > 1):
        print(d - c + 1)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(i) for i in input().split()]
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
else:
    c = a*(n-1) + b
    d = b*(n-1) + a
    if(d - c + 1 > 1):
        print(d - c + 1)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
N,A,B = [int(x) for x in input().split(" ")]

if(A > B) or (N == 1):
	print("0")
else:
	Smin = A * (N - 1) + B
	Smax = B * (N - 1) + A

	print(Smax - Smin + 1)

Submission status: Wrong Answer

Solution code:
N = input().split()

N[0] = int(N[0])
N[1] = int(N[1])
N[2] = int(N[2])

if(N[0] == 1):
    print("0")
    exit()

if(N[1] > N[2]):
    print("0")
    exit()

print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1)

Submission status: Wrong Answer

Solution code:
N,A,B = [int(x) for x in input().split(" ")]

if(A > B):
	print("0")
else:
	Smin = A * (N - 1) + B
	Smax = B * (N - 1) + A

	print(Smax - Smin + 1)

Submission status: Wrong Answer

Solution code:
n,a,b = [int(i) for i in input().split()]
if n == 1:
    print(0)
elif a > b:
    print(0)
else:    
    ans = b*(n-2)-a*(n-2)+1
    print(ans)

Submission status: Wrong Answer

Solution code:

# coding: utf-8

if __name__ == "__main__":
	n, a, b = map(int, input().split())
	if n < b-a+1 or b < a:
		print(0)
	elif n == 1 or n == 2 or a == b:
		print(1)
	else:
		print( (n-2)*(b-a)+1 )

Submission status: Wrong Answer

Solution code:

# coding: utf-8

if __name__ == "__main__":
	n, a, b = map(int, input().split())
	if n < b-a+1:
		print(0)
	elif b < a:
		print(0)
	elif n == 1 or a == b:
		print(1)
	elif n == 2:
		print(3)
	else:
		print( (n-2)*(b-a)+1 )

Submission status: Wrong Answer

Solution code:
N = input().split()

N[0] = int(N[0])
N[1] = int(N[1])
N[2] = int(N[2])

if(N[1] > N[2]):
    print("0")
    exit()

print((N[2] * (N[0] -1) + N[1]) - (N[1] * (N[0] - 1) + N[2]) + 1)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-
import math
N, A, B = map(int, input().split())
if N != 1 and A <= B:
    n = math.factorial(B-A+N-2)
    a = math.factorial(N-2)
    b = math.factorial(B-A)
    print(n/(a*b))
else:
    if A != B:
        print(0)
    else:
        print(1)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ret = 0
if a <= b and n > b - a:
    ret = (n - 2) * (b - a) + 1
print(ret)

Submission status: Wrong Answer

Solution code:
# n = 4, a = 4, b = 6
# 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

"""

n = 5, a = 4, b = 6

44446
44456
44556
45556


45556
45566
45666
46666

(n - 1) (b - a) - (b - a - 1) = 4 * 2 - 1 = 7



n = 5, a = 4, b = 7

44447
44457
44557
45557

45557
45567
45667
46667

46667
46677
46777
47777

(n - 1) (b - a) - (b - a - 1) = 4 * 3 - 2 = 12 - 2 = 10



n = 2, a = 4, b = 7

1 * 3 - 2 = 1




"""


def main():
    n, a, b = map(int, input().split())

    if a > b or n == 1:
        print(0)
        return

    ans = (n - 1) * (b - a) - (b - a - 1)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def FI(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline().split())
def S(): return input()

n, a, b = LI()

if a>b:
	print(0)
else:
	mi = a*(n-1)+b
	ma = a+b*(n-1)
	print(ma-mi+1)

Submission status: Wrong Answer

Solution code:
import math
N, A, B = [int(i) for i in input().split()]

def ncr(n,r):
    if n < 0 or n-r < 0 or r < 0:
        return 1
    return (math.factorial(n)/(math.factorial(r)*math.factorial(n-r)))

print(int(math.ceil(ncr(N + 1, B - A)/2)))

Submission status: Wrong Answer

Solution code:

# coding: utf-8

if __name__ == "__main__":
	n, a, b = map(int, input().split())
	if n < b-a+1:
		print(0)
	elif b < a:
		print(0)
	elif n == 1:
		print(1)
	elif n == 2:
		print(3)
	else:
		print( (n-2)*(b-a)+1 )

Submission status: Wrong Answer

Solution code:
N,A,B = map(int, raw_input().split())
cnt = 0
if(N == 1):
    cnt = 1
elif B > A:
    cnt = (N-2) ** (B-A) + 1

print cnt

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, raw_input().split())

if b - a + 1 > n:
	print 0
elif b < a:
	print 0
else:
	print b * (n - 1) + a - (a * (n - 1) + b) + 1

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, raw_input().split())
if N == 1 and A != B:
    print 0
    exit()
if A > B:
    print 0
if N == 1:
    print 1

print (B - A) * (N - 2) + 1

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
s = 0
if b >= a:
    s = (n-2)*b - (n-2)*a + 1
print(s)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,a,b = LI()
    if n == 1:
        if a == b:
            return 1
        return 0

    if a > b:
        return 0

    if n == 2:
        return 1

    return min((b*(n-1)+a) - (a*(n-1)+b) + 1, n)


print(main())

Submission status: Wrong Answer

Solution code:
length,min_num,max_num = (int(n) for n in input().split(" "))
if min_num > max_num or length == 1:
    print(0)
elif min_num == max_num:
    print(1)
else:
    max_max = max_num * (length - 1) + min_num
    min_min = min_num * (length - 1) + max_num
    print(max_max - min_min + 1)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, raw_input().split())
if N == 1 or A > B:
    print 0
    exit()

print (B - A) * (N - 2) + 1

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n,a,b = LI()
    if n == 1:
        if a == b:
            return 1
        return 0

    if a > b:
        return 0

    return min((b*(n-1)+a) - (a*(n-1)+b) + 1, n)


print(main())