No.333 Counting Kadomatsu Sequences
Problem Statement
A Kadomatsu sequence is defined as follows: when three integers are arranged as A, B, C from left to right,
all the values are distinct and the second largest integer among A, B, C is either A or C.
D-kun obtained one Kadomatsu sequence whose three numbers are each one of the positive integers from 1 to 2000000000.
However, D-kun lost the rightmost number and does not remember it.
Given the left number A and the middle number B, count how many possible values there are for the right number C.
Input
A B
A is the left number of the Kadomatsu sequence, and B is the middle number of the Kadomatsu sequence. $1\le A,B \le 2000000000= 2 \times 10^9$.
Since A and B were originally part of a Kadomatsu sequence, there is no input with an impossible configuration such as A=B.
Output
Output on one line the number of possibilities that answers the problem.
Do not forget the newline at the end.
Sample
Sample 1
Input
2 3
Output
1
For it to be a Kadomatsu sequence, the right number must be 1, so there is only 1 possibility.
Sample 2
Input
2 1
Output
1999999998
The 1999999998 values from 3 to 2000000000 are possible.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
nmnmnmnmnmnmnm