F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Arithmetic Sequence

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1910    Accepted Submission(s): 842


Problem Description
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.
 

Input
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)$.
 

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
 

Author
xudyh
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-21 18:44:01, Gzip enabled