-->
当前位置:首页 > 题库

PROGRAMMING:Reverse order pair

Luz5年前 (2021-05-10)题库535
For an array a [1.. n] containing N non negative integers, if I < J and a [i] > a [J], then (I, J) is called a reverse order pair in array a.
For example, there are four reverse order pairs of array (3, 1, 4, 5, 2) (3,1), (3,2), (4,2), (5,2).
###Input format:
The input contains several groups of data. The first line is an integer t (0 < T < 20), which indicates that there are t groups of test data. Next, each group of test data includes two lines. The first line has only one integer m (0 < m < = 1000), which means that the array has m numbers. The second line has m integers, and the data is separated by spaces.
###Output format:
For each group of test data in the input, output the number of reverse order pairs corresponding to one line.
###Input example:
Here is a set of inputs. For example:
```in
two
five
3 1 4 5 2
ten
1 2 3 4 5 6 7 8 9 10
```
###Output example:
The corresponding output is given here. For example:
```out
four
0
```







answer:If there is no answer, please comment