#K73957. Count Sorted Arrays with Two Distinct Integers

    ID: 34090 Type: Default 1000ms 256MiB

Count Sorted Arrays with Two Distinct Integers

Count Sorted Arrays with Two Distinct Integers

Given three integers n, a, and b where a and b are distinct integers, your task is to compute the number of different sorted arrays of length n that can be formed using only the integers a and b, with the condition that the array contains at least one occurrence of both a and b. A sorted array is a non-decreasing sequence.

If a and b are distinct and n \ge 2, then by choosing the position where the array transitions from one integer to the other, the answer is given by:

[ \text{Answer} = n - 1 ]

If a = b or n < 2, it is impossible to have both numbers in the array, so the answer is 0.

inputFormat

Input consists of a single line containing three integers: n, a, and b, separated by spaces.

outputFormat

Output a single integer, which is the number of possible arrays that satisfy the conditions.## sample

5 2 3
4