8422: Rope Folding

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

Farmer John has a long rope of length L (1 <= L <= 10,000) that he uses forvarious tasks around his farm.  The rope has N knots tied into it at various distinct locations (1 <= N <= 100), including one knot at each of its two endpoints.FJ notices that there are certain locations at which he can fold the rope back on itself such that the knots on opposite strands all line up exactly with each-other:

Please help FJ count the number of folding points having this property. Folding exactly at a knot is allowed, except folding at one of the endpoints is not allowed, and extra knots on the longer side of a fold are not a problem (that is, knots only need to line up in the areas where there are two strands opposite each-other).  FJ only considers making a single fold at a time; he fortunately never makes multiple folds.



农夫约翰有一条长度为 LL 的绳子,可用于农场周围的各种任务。

绳子在不同的位置有 NN 个绳结,包括两个端点处各有一个。

约翰注意到,在某些位置,他可以将绳子对折,这样,相对的绳索上的绳结就可以彼此完全对齐:

fig_knots.png

请帮助约翰统计具有此属性的折叠点数。

允许在某个绳结处折叠,但不允许在端点绳结处折叠。

折叠后,较长的一侧可以有多余节点。



输入格式

INPUT FORMAT: * Line 1: Two space-separated integers, N and L. * Lines 2..1+N: Each line contains an integer in the range 0...L specifying the location of a single knot. Two of these lines will always be 0 and L.



第一行包含两个整数 N 和 L

接下来 N 行,每行包含一个 0∼L 范围内的整数,表示一个绳结的位置。其中两行包含的数字分别是 0和 L



输出格式

* Line 1: The number of valid folding positions. 

输出有效折叠位置的数量。



输入样例 复制

5 10 0 10 6 2 4

输出样例 复制

4