编程介的小学生 2019-01-07 00:38 采纳率: 20.5%
浏览 1255
已采纳

等差数列的问题,采用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

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-12-17 23:24
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办