Title Description
Arithmetic progression is defined as a sequence S, which satisfies (s[i]-s[i-1])
= d (i>1). Obviously a single number or two numbers can also form a arithmetic progression. After a certain study of small c found that the problem is too simple, arithmetic progression and is not (SN+S1) *N/2? Because the problem is simply too simple, little c disdain to solve it. This made little C's teacher angry, and he asked him for another question. The teacher of Little C gave him a sequence of numbers of length n, each with an integer, and he needed a small c to help him find out how many arithmetic progression there were in the number sequence. ...... This problem seems too difficult, small C needs your program to help him to solve the problem.
input
The first line is an integer n, which indicates the length of the number sequence given by the teacher. The second line has n integers a[i], which represents the size of each number in a sequence of numbers.
Output
The output is a single integer, representing the number of arithmetic progression in this sequence (mod 9901).
Sample Input
5 1 4 2 3 7
Sample Output
-
Analysis: Why does this problem ... Because it's interesting. The solution is to define F[I][J] to indicate the number of arithmetic progression with a tolerance of J ending with I. (After this water problem will not send code)
Back to gear |tyvj1091 arithmetic progression