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:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AtoZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N,A,B = IL()

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

Submission status: Wrong Answer

Solution code:
#AGC015-A
n,a,b = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
#AGC015-A
n,a,b = map(int,input().split())

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

elif n == 2:
    print(1)
elif result < 0:
    print(0)
    
else:
    print(result)

Submission status: Wrong Answer

Solution code:
#AGC015-A
n,a,b = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
#AGC015-A
n,a,b = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
#AGC015-A
n,a,b = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
#AGC015-A
n,a,b = map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
#AGC015-A
n,a,b = map(int,input().split())

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N == 1:
    if diff == 0:
        print(0)
    else:
        print(1)
else:
    if diff < 0:
        print(0)
    elif diff == 0:
        print(1)
    else:
        max_val = B * (N-1) + A
        min_val = A * (N-1) + B
        print(max_val - min_val + 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 = list(map(int,input().split()))
if (B * (N-1) + A) - (B + (N-1) * A) <= 0:
  print(0)
elif A == B:
  print(1)
else:
  print((B * (N-1) + A) - (B + (N-1) * A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
if A>B:
  print(0)
  exit()
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 and a != b: print(0)
elif n > 1 and 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((N-1)*B+A-(N-1)*A-B+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:
import sys
input = sys.stdin.readline
from collections import *

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = list(map(int,input().split()))
M = (N[2] - N[1]) * (N[0] - 2) + 1
if N[0] == 1:
    print(1)
elif N[1] == 2:
    print(1)
else:
    print(M)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import itertools
    n,a,b=map(int, input().split())
    if n==1 and a==b:
        print(1)
    elif n==1 and a!=b:
        print(0)
    elif b<a:
        print(0)
    else:
        print((a+3*b)-(3*a+b)+1)
resolve()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,A,B=MI()
    N-=1
    if(A>B or (N==1 and A!=B)):
        print(0)
        return
    print(B*N+A-(A*N+B)+1)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

minSum = A * (N-1) + B
maxSum = A + B * (N-1)
print(maxSum-minSum+1)

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if N == 0 or A > B:
    print(0)
    quit()

minSum = A * (N-1) + B
maxSum = A + B * (N-1)
print(maxSum-minSum+1)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def answer(n, a, b):
    if (a > b) or (n < 2): return 0
    n = n-2
    small = a*n
    big = b*n
    return big - small + 1

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

Submission status: Wrong Answer

Solution code:
def answer(n, a, b):
    if a > b: return 0
    if n < 2: return 0
    n = n-2
    small = a*n
    big = b*n
    return big - small + 1

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

Submission status: Wrong Answer

Solution code:
def answer(n, a, b):
    n = n-2
    small = a*n
    big = b*n
    return big - small + 1

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

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)
su = 0
for i in range(1,l-1):
 # print(su)
  if s[i]=="U":
    su += 1*(l-1-i)+2*(i)
  else:
    su += 1*(i)+2*(l-i-1)
print(su+2*(l-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# A - A+...+B Problem

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

if A>B or (N==1 and 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(x) for x in input().split())
if N == 1:
    if A != B:
        print('0')
    else:
        print('1')
elif A > B:
    print('0')
elif A == B:
    print('1')
else:
    print((N-2)*(B-A+4-N)+1)

Submission status: Wrong Answer

Solution code:
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy

# import heapq
# from collections import deque
# import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===

def main():
    n, a, b = ns()

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

    if a > b or n < 2:
        print(0)
        exit(0)

    minimum_sum = a * n + (b - a)
    maximum_sum = a * n - (b - a)
    print(maximum_sum - minimum_sum + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


    print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import scipy
import itertools

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

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
import scipy
import itertools

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

if __name__ == "__main__":
    solve()

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

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:
    print((b - a) * (n - 1) - 1)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
if B < A:
  print(0)
  exit()
num = B-A+1
mi = A*(N-1) + B
ma = B*(N-1) + A
ans = ma - mi + 1

print(ans)

Submission status: Wrong Answer

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

if b-a < 0 or n == 1:
    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 b-a < 0:
    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 b-a < 0:
    print(0)
elif a == b:
    print(1)
elif b-a+1 < n:
    print((n-2)**2+1)
else:
    print((n-2)**3+1)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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


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

Submission status: Wrong Answer

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


if b - a >= n:
    print(0)
elif 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())
print((b - a) * (n - 2) + 1)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int, input().split())
#最小がA　最大がB　その区間でN個
if A>B:
    print(0)
    exit()
elif N==1 and A!=B:
    print(0)
    exit()
MAX=A+B*(N-1)
MIN=B+A*(N-1)
print(MAX, MIN)
print(MAX-MIN+1)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B=MI()
    ans=0
    rem=N-2
    ans=rem*(B-A)+1
    ans=max(ans,0)
    if A>B or rem<0:
        ans=0
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,A,B=MI()
    ans=0
    rem=N-2
    rem=max(rem,0)
    ans=rem*(B-A)+1
    ans=max(ans,0)
    if A>B or rem==0:
        ans=0
    print(ans)

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def myAnswer(N:int,A:int,B:int) -> int:
   if(B - A+1 > N or B - A < 0): return 0
   ans = (B*(N-1) + A) - (A * (N - 1) + B) + 1
   return ans

def modelAnswer():
   return
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))
if __name__ == '__main__':
   main()

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,A,B = map(int,input().split())

if N == 0:
    print(0)
    exit()
elif N == 1 and A==B:
    print(1)
    exit()
elif N == 1 and A!=B:
    print(0)
    exit()
elif A>B:
    print(0)
    exit()
elif N==2:
    print(1)
    exit()
else:
    n = N-2
    ans = B*n - A*2 +1
    print(ans)
    exit()
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int, input().split())
a = (b-a+1)**(n-2)/ 2
f = a - int(a)
if f == 0.5:
    ans = int(a) + 1
else:
    ans = round(a)
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc015/tasks/agc015_a

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

if b < a:
    print(0)
elif a != b and n == 1:
    print(0)
else:
    t = b - a + 1
    ans = math.factorial(t + n - 1) // (math.factorial(t) * math.factorial(n))
    print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/agc015/tasks/agc015_a

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

if b < a:
    print(0)
else:
    t = b - a + 1
    ans = math.factorial(t + n - 1) // (math.factorial(t) * math.factorial(n))
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
if B - A + 1 > N:
  print(0)
  exit()
if A > B:
  print(0)
  exit()
s1 = A * (N - B + A)
s2 = B * (N - B + A)
print(s2 - s1 + 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= list(map(int, input().split()))
if a>b:
    print("0")
    exit(0)
if n==1:
    if a!=b:
        print("0")
    else:
        print("1")
    exit(0)
n-=2;b-=a;a=0
if n>=b:
    print(b*n+1)

Submission status: Wrong Answer

Solution code:
n,a,b= list(map(int, input().split()))
if a>b:
    print("0")
    exit(0)
elif n==1:
    if a!=b:
        print("0")
    else:
        print("1")
    exit(0)
n-=2;b-=a;a=0
if n>=b:
    print(b*n+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)
elif N == 1 and A == B:
    print(1)
elif N == 2 and A != B:
    print(1)
else:
    print(1000)

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)
elif N == 1 and A == B:
    print(1)
elif N == 2 and A != B:
    print(1)
print(1000)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    L=list(map(int,input().split()))
    prod=L[0]*L[1]*L[2]
    ans=10**20
    for i in L:
        if i%2==0:
            ans= 0
            break
        else:
            ans=min(ans,prod//i)
    print(ans)


resolve()

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, MIN, MAX = map(int, input().split())

sum_min = (N-1)*MIN + MAX
sum_max = (N-1)*MAX + MIN
# print(sum_max)
# print(sum_min)

if N > 1:
    print(sum_max - sum_min + 1)
elif N == 1:
    if MIN!= MAX:
        print(0)
    else:
        print(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)
elif n == 2:
  if a == b or a < b:
    print(1)
  else:
    print(0)
else:
  if  a > b:
    print(0)
  else:
    print((b - a) * (n - 2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

smin = (N-1)*A + B
smax = A + (N-1)*B
print(smax-smin+1)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, A, B = MI()

    if A > B:
        print(0, 1)
        return

    if A != B and N == 1:
        print(0)
        return

    min_v = A * (N - 1) + B
    max_v = A + B * (N - 1)
    print(max_v - min_v + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, A, B = MI()

    if A > B:
        print(0)
        return

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

    min_v = A * (N - 1) + B
    max_v = A + B * (N - 1)
    print(max_v - min_v + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    ans = 0

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

    print(ans)

Submission status: Wrong Answer

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

    ans = 0

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

    print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = (int(i) for i in input().split())
    if (N == 1 and A != B) or (B - A < 0):
        print(0)
    elif N == 1:
        print(1)
    elif N == 2:
        print(1)
    elif B - A == 1 and N == 3:
        print(B - A + 1)
    else:
        print(2*B - 2*A + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = (int(i) for i in input().split())
    if (N == 1 and A != B) or (B - A < 0):
        print(0)
    elif N == 1:
        print(1)
    elif N == 2:
        print(1)
    else:
        print((B-A)*B - (B-A)*A + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N, A, B = (int(i) for i in input().split())
    if (N == 1 and A != B) or (B - A < 0):
        return print(0)
    print(2*B - 2*A + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

min_  = a + a*(n-2) + b
max_ = a + b*(n-2) + b

print(max(0, max_-min_+1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(mx-mn+1)

Submission status: Wrong Answer

Solution code:
import math
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 = math.ceil((diff**(n-2))/2)
    if n%2==0:
        print(int(ans))
    else:
        print(int(ans)+1)