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:
    print(0)
elif n < (b-a+1) or (a-b==0 and n > 1):
    print(0)
else:
    diff = b-a+1
    ans = (diff**(n-2))//2+1
    print(int(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,a,b = get_nums_l()

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

if n == 1:
    if a==b:
        print(1)
    else:
        print(0)
    exit()

if n == 2:
    print(1)
    exit()

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

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,a,b = get_nums_l()

if n == 1:
    if a==b:
        print(1)
    else:
        print(0)
    exit()

if n == 2:
    print(1)
    exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if(A > B):
  print(0)
elif (A == B):
  if (N == 1):
    print(1)
  else:
    print(0)
else:
  if (N == 1):
    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):
  print(0)
elif (A == B):
  if (N == 1):
    print(1)
  else:
    print(0)
else:
  if (N == 1):
    print(0)
  elif (N == 2):
    print(1)
  else:
    print((B-A)*(N-2) + 1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if A == B:
    ans = 1
elif A > B:
    ans = 0
else:
    ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
方針
O(1)
"""
#solution:
#潜 影 蛇 手 ! !
N,A,B=pin()
if A==B:
    print(1)
elif A>B or N==1:
    print(0)
else:
    print((N-1)*(B-A)-1)
#print(["NO","YES"][1-cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])

Submission status: Wrong Answer

Solution code:
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
方針
O(1)
"""
#solution:
#潜 影 蛇 手 ! !
N,A,B=pin()
if A==B:
    print(1)
elif A>B or N==1:
    print(0)
else:
    print((N-1)*(B-A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
if a > b :
         print(0)
         exit()
elif n == 1:
         print(0)
         exit()
else:
         print((b-a)*2+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:
  k = b-a
  if k < 0:
    print(0)
  elif k==0:
    print(1)
  else:
    print(b*k - a*k+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# AGC015a
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

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

if n == 1:
	if a == b:
		print(1)
	else:
		print(0)
		sys.exit()
if a > b:
	print(0)
	sys.exit()

maximum = (a+b) + b*(n-2)
minimum = (a+b) + a*(n-2)

print(maximum-minimum+1)

Submission status: Wrong Answer

Solution code:
import sys

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

if a >= b:
	print(0)
	sys.exit()
if n < 2:
	print(0)
	sys.exit()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, a, b = LI()
    print(b * n + a - b - (a * n - a + b - 1))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, a, b = LI()
    print(b * n + a - b - (a * b - a + b - 1))
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import os
if sys.platform=="darwin":
   base = os.path.dirname(os.path.abspath(__file__))
   name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
   #print(name)
   sys.stdin = open(name)

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

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

if b-a+1 == n:
   print(1)
   exit()
elif b-a+1 > n:
   print(0)
   exit()

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 b-a+1 > n:
	ans=0
else:
	mini= a*(n-1)+b
	maxi= a+(n-1)*b
	ans=maxi-mini+1
print(ans)

Submission status: Wrong Answer

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

if a > b or (a < b and n == 1):
    print(0)
elif (a == b and 1 <= n <= 2) or (a < b and n == 2):
    print(1)
elif (a < b) and n >= 3:
    print((b-a)*(n-2)+1)

Submission status: Wrong Answer

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

if a > b or (a < b and n == 1):
    print(0)
elif (a == b and n == 1) or (a < b and n == 2):
    print(1)
elif (a < b) and n >= 3:
    print((b-a)*(n-2)+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

maxi=(N-1)*B + A
mini=(N-1)*A + B

ans = maxi - mini +1

print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int , input().split())
if a > b or n < 2:
    print(0)
elif a == b or (n == 1 and a == b):
    print(1)
else:
    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 or a > b:
    ans = 0
else:
    min_num = b + (a * (n - 1))
    max_num = a + (b * (n - 1))
    ans = max_num - min_num + 1

print(ans)

Submission status: Wrong Answer

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

if n == 1 or a > b:
    ans = 0
elif n == 2:
    ans = 1
else:
    min_num = b + (a * (n - 1))
    max_num = a + (b * (n - 1))
    ans = max_num - min_num + 1

print(ans)

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:
# 2019-11-22 16:25:33(JST)
import sys


def main():
    n, a, b = [int(x) for x in sys.stdin.readline().split()]


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def calc():
    n, a, b = map(int, input().split())
    if a > b:
        return 0
    if n == 1 and a < b:
        return 0

    lower = a + b * (n - 1)
    upper = b + a * (n - 1)
    return upper - lower+1


print(calc())

Submission status: Wrong Answer

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

if A > B or B - A > N:
    print(0)

else:
    if A == B:
        print(1)
    else:
        if B - A > 1:
            print((N - 2) + (B - A + 1))

        else:
            print((N - 2) + (B - A))

Submission status: Wrong Answer

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

if A > B or B - A > N:
    print(0)

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

Submission status: Wrong Answer

Solution code:
def accumulate(a, b):
    k = b - a + 1
    return k * (k+1) // 2 + k * (a-1)

def solve(n, a, b):
    if b < a:
        return 0
    if b - a + 1 > n:
        return 0
    if n == 1:
        if a == b:
            return 1
        else:
            return 0
    else:
        return (b - a) * (n - 2) + 1

n, a, b = map(int, input().split())
print(solve(n, a, b))

Submission status: Wrong Answer

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

if(B-A<0):
    print("0")
    exit()
if(A==B):
    if(N==1):
        print("1")
        exit()
    else:
        print("0")
        exit()
if(N==1):
    if(A==B):
        print("1")
        exit()
    else:
        print("0")
        exit()

if(N==2):
    print("1")
    exit()

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

Submission status: Wrong Answer

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

if n >= 2:
    if b > a:
        print((n-2)*(b-a)+1)
    else:
        print(0)
else:
    if a == b:
        print(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:
N,A,B=map(int,input().split())
print((B-A)*(N-2)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


if __name__ == "__main__":
    resolve()

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:
    sum_max=A+B+(N-2)*A
    sum_min=A+B+(N-2)*B
    print(sum_max-sum_min+1)

Submission status: Wrong Answer

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

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

if A >= B:
    print(0)
    exit()
elif N == 1 and A != B:
    print(0)
    exit()

digit = N - 1
min_calc = A*digit + B
max_calc = A + B*digit
ans = max_calc - min_calc + 1

print(ans)

Submission status: Wrong Answer

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

if N == 1 and A != B:
    print(0)
    exit()
if N == 1 and A == B:
    print(1)
    exit()
elif A >= B:
    print(0)
    exit()

digit = N - 1
min_calc = A*digit + B
max_calc = B*digit + A
ans = max_calc - min_calc + 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0
tmp = list()
if (n == 1):
  if (a == b):
    cnt += 1
elif (a < b) :
  for j in range(a,b+1):
    for k in range(a,b+1):
      sum = j + k
      if (sum not in tmp) :
        tmp.append(sum) 
        cnt += 1
print(cnt)

Submission status: Wrong Answer

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

cnt = 0
tmp = list()
if (a < b) :
  for j in range(a,b+1):
    for k in range(a,b+1):
      sum = j + k
      if (sum not in tmp) :
        tmp.append(sum) 
        cnt += 1
elif (n == 1):
  if (a == b):
    cnt += 1
print(cnt)

Submission status: Wrong Answer

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

cnt = 0
sum = a + b
tmp = list()
if (a < b) :
  for j in range(a,b+1):
    for k in range(a,b+1):
      sum = j + k
      if (sum not in tmp) :
        tmp.append(sum) 
        cnt += 1
elif (n == 1):
  cnt += 1
print(cnt)

Submission status: Wrong Answer

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

cnt = 0
sum = a + b
tmp = list()
if (a < b and n != 1) :
  for j in range(a,b+1):
    for k in range(a,b+1):
      sum = j + k
      if (sum not in tmp) :
        tmp.append(sum) 
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
s = list(s)
s.sort()
ans = list("abc")
if (s == ans):
  print("Yes")
else :
  print("No")

Submission status: Wrong Answer

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

if a == b:
  print(1)

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

mid_num = n - 2

if mid_num < 0:
  print(0)
  exit()

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

Submission status: Wrong Answer

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

if a == b:
  if n == 1:
    print(1)
    exit()
  else:
    print(0)
    exit()

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

mid_num = n - 2

if mid_num < 0:
  print(0)
  exit()

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
#結局、上限はA+B*(N-1)、下限はA*(N-1)+B
print(A+B*(N-1) - (A*(N-1)+B) + 1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
import sys
if a >= b:
    print(0)
    sys.exit()
m_max = a + b*(n-1)
m_min = b + a*(n-1)
print(m_max-m_min+1)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
import sys
if b-a+1 > n:
    print(0)
    sys.exit()
m_max = a + (n-1)*b
m_min = b + (n-1)*a
print(m_max-m_min+1)

Submission status: Wrong Answer

Solution code:
N, A, B = [int(i) for i in input().split()]
res = max(0, (N-2) * B - (N-2) * B + 1)
print(res)

Submission status: Wrong Answer

Solution code:
n, a, b = [ int(v) for v in input().split() ]
if n == 1:
    if a != b:
        ans = 1
    else:
        ans = 0
else:
    if a <= b:
        maxsum = a + b*(n-1)
        minsum = a*(n-1) + b
        ans = maxsum - minsum + 1

    else:
        ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = [ int(v) for v in input().split() ]
if n == 1:
    if a != b:
        ans = 1
    else:
        ans = 0
else:
    if a <= b:
        maxsum = a + b*(n+1)
        minsum = a*(n+1) + b
        ans = maxsum - minsum + 1

    else:
        ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
# 2019/08/20

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

print(max((2*b-2*a+1),0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if (a > b) : print(0)
elif (a == b) :
  if (n == 1) : print(1)
  else : print(0)
elif (n == 1) : 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) : print(0)
elif (a == b) :
  if (n == 1) : print(1)
  else : print(0)
elif (n == 1) : print(0)
else : print(b*(n-1)+a-a*(n-1)-b+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
if (a < b) : print(0)
else : print(b*(n-1)+a-a*(n-1)-b+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 A > B :
    ans = 0
elif A == B :
    ans = 1
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())
min_a_b = a * (n-1) + b
max_a_b = a + b * (n-1)
print(max_a_b - min_a_b + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 3 .. 6 N=4とすると真ん中2つは(3, 3)~(6, 6)までで、1ずつインクリメントして全種類網羅できる
# 3+3 ~ 6+6までの12-6+1種類
n, a, b = map(int, input().split())
if b < a or n == 1:
    print(0)
elif n == 2 and a <= b:
    print(1)
else:
    minn = (n - 2) * a
    maxn = (n - 2) * b
    print(maxn - minn + 1)

Submission status: Wrong Answer

Solution code:
# 3 .. 6 N=4とすると真ん中2つは(3, 3)~(6, 6)までで、1ずつインクリメントして全種類網羅できる
# 3+3 ~ 6+6までの12-6+1種類
n, a, b = map(int, input().split())
if b < a:
    print(0)
elif n == 2 and a <= b or n == 1:
    print(1)
else:
    minn = (n - 2) * a
    maxn = (n - 2) * b
    print(maxn - minn + 1)

Submission status: Wrong Answer

Solution code:
# 3 .. 6 N=4とすると真ん中2つは(3, 3)~(6, 6)までで、1ずつインクリメントして全種類網羅できる
# 3+3 ~ 6+6までの12-6+1種類
n, a, b = map(int, input().split())
if n == 1 or b < a:
    print(0)
elif n == 2 and a <= b:
    print(1)
else:
    minn = (n - 2) * a
    maxn = (n - 2) * b
    print(maxn - minn + 1)

Submission status: Wrong Answer

Solution code:
# 3 .. 6 N=4とすると真ん中2つは(3, 3)~(6, 6)までで、1ずつインクリメントして全種類網羅できる
# 3+3 ~ 6+6までの12-6+1種類
n, a, b = map(int, input().split())
if n == 1 or b < a:
    print(0)
elif n == 2 and a <= b:
    print(1)
else:
    minn = (n - 2) * a
    maxn = (n - 2) * b
    print(minn, maxn)
    print(maxn - minn + 1)

Submission status: Wrong Answer

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

q = B - A + 1

if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
    exit()

if N == 2:
    print(1)
    exit()

c = N - 2
print((q ** c) - q)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

N -= 1
if A != B:
  N -= 1

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

Submission status: Wrong Answer

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

N -= 1
if A != B:
  N -= 1

if N < 0:
  ans = 0
else:
  M = B - A
  ans = 1
  for k, m in zip(range(M + N, 0, -1), range(1, N+1)):
    ans *= k
    ans //= m

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
N,A,B = [int(x) for x in stdin.readline().rstrip().split()]
min_ = A * (N - 1) + B
max_ = B * (N - 1) + A
print(max_ - min_ + 1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python
# coding: UTF-8

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

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

n = B-A
if A > B or n >= N:
    print(0)
else:
    print(A+3*B-A*3-B+1)

Submission status: Wrong Answer

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

n = B-A
if A > B or n > N:
    print(0)
else:
    print(A+3*B-A*3-B+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
print((b-a)*(n-2)+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((b-a)*(n-2)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A > B:
    print(0)
else:
    if N == 1:
        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:
    if N == 1:
        print(1)
    else:
        print(0)
elif A > B:
    print(0)
else:
    if N == 1:
        print(0)
    else:
        print((B-A)*(N-2)+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, m, k = [int(i) for i in input().split()]
if n == 1 or m > k:
    print(m == k)
else:
    print(k * (n - 1) + m - m * (n - 1) - k + 1)