#abc369c. C - Count Arithmetic Subarrays
C - Count Arithmetic Subarrays
Score : points
问题陈述
给定一个正整数序列 。
找出满足 的整数对 的数量,使得子序列 构成一个等差数列。
如果存在一个 使得 ,则序列 是一个等差数列。特别地,长度为 的序列总是一个等差数列。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
You are given a sequence of positive integers .
Find the number of pairs of integers satisfying such that the subsequence forms an arithmetic progression.
A sequence is an arithmetic progression if and only if there exists a such that . In particular, a sequence of length is always an arithmetic progression.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
3 6 9 3
Sample Output 1
8
There are eight pairs of integers satisfying the condition: .
Indeed, when , is an arithmetic progression, so it satisfies the condition. However, when , is not an arithmetic progression, so it does not satisfy the condition.
Sample Input 2
5
1 1 1 1 1
Sample Output 2
15
All pairs of integers satisfy the condition.
Sample Input 3
8
87 42 64 86 72 58 44 30
Sample Output 3
22