There are N people stand in a line. The ith person has a number Pi. If the Pi and Pj have a common prime factor X when
[p(i + 1) … p(j - 1)] can not be divisible by X, we will call the ith person and the jth person is a couple of friends.
Two numbers l and r can divide the line into 3 parts, [1 … l], [l + 1 … r - 1] and [r … N]. We call [1 … l] and [r … N] block A,
[l + 1 … r - 1] block B, and we define F(l , r) as the number of the couples in A minus the number of the couples in B.
Now, I have a favorite number C, can you figure out how many groups of l and r satisfies F(l , r)=C?10 2 1 2 3 4 5 5 4 3 2 1 9 2 1 3 6 7 15 4 12 1 14
4 4
In the second sample. In total, 7 pairs friends among the 9 persens, (2,3), (3,5), (3,6), (4,9), (5,7), (6,7), (7,9). when (l=1 and r=5) or (l=3 and r=7) or (l=5 and r=8) or (l=5 and r=9) is satisfies F(l, r)=2. So, the answer of the sample is 4.
岁月静好@DLMU