#Lutece2818. Niuma的rating
Niuma的rating
Migrated from Lutece 2818 Niuma的rating
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
闲来无事,于是打开了 ,查看自己的 曲线,突然他发现自己的 曲线呈现出某种重复的特征,如图中所示,在 连续的三段时间里, 段和 段自己的曲线的趋势完全相同(即平移后可以重合)。现在有了一个奇怪的想法,他想固定 段时间的长度,同时询问你 曲线中有多少个连续的子段,满足将其分解为 三段后, 段的长度为给定的 ,且 两段的变化趋势相同。
Input
第一行两个整数 ,表示总共打了 次 ,他希望固定的B段的时间长度为 ,你可以认为两次相邻的 之间的时间长度总是为 第二行 个正整数 表示每次
Output
一行一个整数,表示满足条件的子段数量
Samples
15 2
1 1 3 2 8 8 8 4 6 5 5 5 1 3 2
3
Constraints
,
Note
对于样例,和题干中图例一样,满足条件的子段为 以 这一段为例,可以发现以 作为 段(时间长度为 ),前后的趋势恰好相同,所以满足条件
Resources
2022 UESTC ICPC Training for String and Search Algorithm