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: Accepted

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

print (max(B * (N - 1) + A - (A * (N - 1) + B) + 1, 0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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 * (n - 2) - a * (n - 2) + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if N == 1 :
    if A != B :
        ans = 0
    else :
        ans = 1



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

print(ans)

Submission status: Accepted

Solution code:
def main():
    n,a,b = map(int,input().split())
    if a>b:
        print(0)
    elif n==1 and a!=b:
        print(0)
    else:
        sum_min = a+b+a*(n-2)
        sum_max = a+b+b*(n-2)
        print(sum_max-sum_min+1)
if __name__ == '__main__':
    main()

Submission status: Accepted

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(0, max_a_b - min_a_b + 1))

Submission status: Accepted

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

    

main()
#A, .,  ., ., ..., B

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AGC015A - A+...+B Problem
def main():
    n, a, b = tuple(map(int, input().rstrip().split()))
    if a > b or (n == 1 and a != b):
        print(0)
    elif n == 1 and a == b:
        print(1)
    else:
        print((n - 2) * (b - a) + 1)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N, A, B = mi()

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

if A>B:
  print(0)
  exit()

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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-2)+1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N, A, B = map(int, input().split()) # 横に2個

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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: Accepted

Solution code:
# 3 .. 6 N=4とすると真ん中2つは(3, 3)~(6, 6)までで、1ずつインクリメントして全種類網羅できる
# 3+3 ~ 6+6までの12-6+1種類
# n>1 a<bが条件になってないっていう非本質的な小賢しい罠

n, a, b = map(int, input().split())
if a == b and n == 1:
    print(1)
elif 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: Accepted

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

if A > B:
	print(0)
	exit()

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

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

sum_min, sum_max = A * (N - 1) + B, A + (N - 1) * B

print(sum_max - sum_min + 1)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

x = A * (N-1) + B
y = B * (N-1) + A

if N == 1 and A != B:
  answer = 0
elif A > B:
  answer = 0
else:
  answer = y - x + 1

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
#A問題
N,A,B = map(int,input().split())
dif = B-A
n = N-2
print(max(n*dif+1,0))

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
nums , num_1 , num_2 = map(int,input().split())
if (num_2 < num_1) or (nums == 1 and num_1 != num_2):
    print(0)
else:
    print((num_2 - num_1) * (nums - 2) + 1)

Submission status: Accepted

Solution code:
#!/usr/bin/python
# coding: UTF-8
 
n, a, b = map(int,input().split())
 
if n == 1:
  print(1 if a == b else 0)
else:
  print((b - a)*(n - 2) + 1 if b >= a else 0)

Submission status: Accepted

Solution code:
#!/usr/bin/python
# coding: UTF-8
 
n, a, b = map(int,input().split())
 
if n == 1:
  print(1 if a == b else 0)
else:
  if b >= a:
    print((b - a)*(n - 2) + 1)
  else:
    print(0)

Submission status: Accepted

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

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

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

Submission status: Accepted

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 * (n-2) - a * (n-2) + 1) 
else:
  print(0)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N ,A,B  =list(map(int,input().split(" ")))
N - 2
ab = A+B

if  A > B : #異常値
    print(0)

elif N == 1 :
    if A==B:
        print(1)
    else:
        print(0)
elif N==2:
    print(1)
else:
    minsum = (N-2) * A + ab
    maxsum = (N-2) * B + ab

    print(maxsum - minsum + 1)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
A - A+...+B Problem
https://atcoder.jp/contests/agc015/tasks/agc015_a

"""
import sys


def solve(N, A, B):
    if A > B:
        return 0
    if N == 1 and A != B:
        return 0
    left = A * (N - 2)
    right = B * (N - 2)
    return right - left + 1


def main(args):
    N, A, B = map(int, input().split())
    ans = solve(N, A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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

Submission status: Accepted

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-2)+1)

Submission status: Accepted

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

Submission status: Accepted

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-2)+1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math

INF = float('inf')
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 LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


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

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


print(main())

Submission status: Accepted

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

if (N == 1 and A != B) or A > B:
  print(0)
else:
  ans = 1 + max(0,(N-2))*(B-A)
  print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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) + 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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-2)+1)

Submission status: Accepted

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

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

    print(mx - mn + 1)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
nums = input()
nums = nums.split(' ')
n = int(nums[0])
a = int(nums[1])
b = int(nums[2])
if n == 1:
    if a == b:
        print(1)
    else:
        print(0)
    exit(0)
if a > b:
    print(0)
    exit(0)
num = b*(n-2) - a*(n-2) + 1
print(num)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


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

    if a > b or (n == 1 and a != b):
        print(0)
    else:
        print(max(0, b - a) * (n - 1) + (a - b) + 1)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

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

Submission status: Accepted

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

Submission status: Accepted

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)*N+1
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(max(0, (A+B*(N-1))-(B+A*(N-1))+1))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(max(B*(N-1)+A - A*(N-1)-B + 1, 0))

Submission status: Accepted

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

print(max(0,(B*(N-1)+A)-(A*(N-1)+B)+1))

Submission status: Accepted

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

Submission status: Accepted

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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, A, B = MAP()

if A > B:
    print(0)
elif A == B:
    print(1)
else:
    if N < 2:
        print(0)
    elif N == 2:
        print(1)
    # A < B でNも3つ以上あれば色々できる
    else:
        print(A + B*(N-1) - (A*(N-1) + B)+1)

Submission status: Accepted

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

min_sum = a * (n - 1) + b
max_sum = b * (n - 1) + a

print(max(max_sum - min_sum + 1, 0))

Submission status: Accepted

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

min_sum = a * (n - 1) + b
max_sum = b * (n - 1) + a

print(max(max_sum - min_sum + 1, 0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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