values of distinct positive integers. Count the ordered quadruples (a, b, c, d) of four different elements of the array such that a · b = c · d.
Quadruples that differ only in order are counted separately: for example, (2, 6, 3, 4) and (6, 2, 3, 4) are two different quadruples.values=[3, 4, 6, 8] → 8
3 · 8 = 4 · 6 = 24. These two pairs give 8 quadruples: (3, 8, 4, 6), (8, 3, 4, 6), (3, 8, 6, 4), (8, 3, 6, 4), plus four more with the pairs swapped.
values=[1, 3, 5, 7] → 0
All six pairwise products are different, so there is no valid quadruple.
values=[1, 2, 3, 4, 6, 12] → 40
values=[3, 4, 6, 8]
8
Run checks the first 3 tests in your browser. Submit checks all 92 tests on the server, hidden ones included.