#P1881. 绳子对折
绳子对折
Description
FJ has a rope of length (). There are () knots on the rope, including the two endpoints. FJ wants to fold the rope so that the knots on the shorter side coincide exactly with the knots on the longer side, as shown in the figure:

Find how many valid folding positions FJ can choose.
Input Format
The first line: two integers, and .
Lines to : each line contains one integer giving the position of a knot. Among them, and are always included.
Output Format
The first line: one integer, the number of valid folding positions.
5 10
0
10
6
2
4
4
Hint
(You can fold at positions 1, 2, 3, and 8.)
Translated by ChatGPT 5
京公网安备 11011102002149号