#P8912. Counting Integer Triplets
Counting Integer Triplets
Counting Integer Triplets
Given a non-decreasing sequence ( [a_1,a_2,a_3,\dots,a_n] ) (i.e. ( a_i \leq a_{i+1} ) for every ( i\in [1,n-1])), count the number of integer triplets ( (i,j,k) ) that satisfy the following conditions:
- ( 1\leq i,j,k\leq n ).
- ( a_i\times j\times a_k=i+a_j+k ).
Note: The sequence is 1-indexed and all formulas are shown in ( \LaTeX ) format.
inputFormat
The first line contains an integer ( n ), the number of elements in the sequence. The second line contains ( n ) space-separated integers ( a_1,a_2,\dots,a_n ) representing a non-decreasing sequence.
outputFormat
Output a single integer: the number of triplets ( (i,j,k) ) that satisfy ( a_i\times j\times a_k=i+a_j+k ).
sample
1
2
1
</p>