AtCoder- A+…+B Problem
These N integers belong to the interval [A,B], then the smallest sum of these N numbers may be A+A+…+A+B=(N-1)A+B, the largest It may be A+B+B+…+B=A+(N-1)B, so the possible number is (n-1)*b+a -(n-1)*ab +1
int main()
{
cin>>n;
cin>>a>>b;
if(a > b || (n <= 1 && a != b) ) {
cout<<0;
return 0;
}
cout<<(n-1)*b+a -(n-1)*a-b +1;
return 0;
}