Back to gear |tyvj1091 arithmetic progression

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.