#P8196. [传智杯 #4 决赛] 三元组
[传智杯 #4 决赛] 三元组
Background
Problem Description
Given a sequence of length , for an ordered integer triple , if it satisfies and , then we call this triple “ChuanZhi’s”.
Now please compute how many ordered integer triples are “ChuanZhi’s”.
Input Format
This problem contains multiple groups of testdata in a single test case.
The first line of input is an integer , indicating the number of test cases.
For each test case:
The first line is an integer, representing the length of the sequence .
The second line contains integers, where the -th integer represents .
Output Format
For each test case, output one line with one integer representing the answer.
2
3
1 2 3
5
1 2 3 4 5
2
6
Hint
Explanation for Sample 1
For the first test case, since and , there are triples in total: and .
For the second test case, the six triples are:
Constraints
For all test points, it is guaranteed that , , and the sum of over all test cases does not exceed , i.e. .
Translated by ChatGPT 5