values. Look at ordered triples of pairwise distinct indices (i, j, k). A triple counts if the sum values[i] + values[j] + values[k] is divisible by exactly one of the three numbers values[i], values[j], values[k].
The three numbers are judged as separate elements: if two of them are equal and both divide the sum, that is two divisors, not one.
Return the number of such triples. Order matters: (0, 1, 2) and (1, 0, 2) are different triples.values=[2, 3, 4] → 6
The sum 2 + 3 + 4 = 9 is divisible by 3 only. The indices 0, 1, 2 work in all 6 orders.
values=[5, 5, 1, 2] → 12
5 + 5 + 1 = 11 is divisible only by 1, giving 6 ordered triples; 5 + 5 + 2 = 12 is divisible only by 2, giving 6 more. A triple 5, 1, 2 sums to 8, divisible by both 1 and 2, so it does not count. Total: 12.
values=[3, 3, 3] → 0
values=[2, 3, 4]
6
Run checks the first 3 tests in your browser. Submit checks all 88 tests on the server, hidden ones included.