当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5400:Arithmetic Sequence

题目描述
A sequence $b_1,b_2,\cdots,b_n$ are called $(d_1,d_2)$-arithmetic sequence if and only if there exist $i(1\leq i\leq n)$ such that for every $j(1\leq j<i),b_{j+1}=b_j+d_1$ and for every $j(i\leq j<n),b_{j+1}=b_j+d_2$.

Teacher Mai has a sequence $a_1,a_2,\cdots,a_n$. He wants to know how many intervals $[l,r](1\leq l\leq r\leq n)$ there are that $a_l,a_{l+1},\cdots,a_r$ are $(d_1,d_2)$-arithmetic sequence.
输入解释
There are multiple test cases.

For each test case, the first line contains three numbers $n,d_1,d_2(1\leq n\leq 10^5,|d_1|,|d_2|\leq 1000)$, the next line contains $n$ integers $a_1,a_2,\cdots,a_n(|a_i|\leq 10^9)$.
输出解释
For each test case, print the answer.
输入样例
5 2 -2
0 2 0 -2 0
5 2 3
2 3 3 3 3
输出样例
12
5
来自杭电HDUOJ的附加信息
Author xudyh
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5400

最后修改于 2020-10-25T23:22:21+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
4000/2000MS(Java/Others) 65536/65536K(Java/Others)