编程介的小学生
2019-03-15 16:54行列式绝对值数字序列的问题求值,运用C语言算法编程的技术
Problem Description
A sequence b1,b2,⋯,bn are called (d1,d2)-arithmetic sequence if and only if there exist i(1≤i≤n) such that for every j(1≤j<i),bj+1=bj+d1 and for every j(i≤j<n),bj+1=bj+d2.
Teacher Mai has a sequence a1,a2,⋯,an. He wants to know how many intervals l,r there are that al,al+1,⋯,ar are (d1,d2)-arithmetic sequence.
Input
There are multiple test cases.
For each test case, the first line contains three numbers n,d1,d2(1≤n≤105,|d1|,|d2|≤1000), the next line contains n integers a1,a2,⋯,an(|ai|≤109).
Output
For each test case, print the answer.
Sample Input
5 2 -2
0 2 0 -2 0
5 2 3
2 3 3 3 3
Sample Output
12
5
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- VC++游戏编程课本问题:这个地图的行列怎么反着表示呢?
- c++
- 1个回答
- mysql 中存储过程动态生成sql语句执行的问题
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
- ASP中计算table行数问题
- it技术
- 互联网问答
- IT行业问题
- 计算机技术
- 编程语言问答
- 0个回答
- C语言二维数组输出矩阵
- c
- 二维数组
- 4个回答
- 求C语言大神赐教。。。。
- c语言
- 4个回答
换一换