#K37262. Unique Product of Distinct Elements

    ID: 25938 Type: Default 1000ms 256MiB

Unique Product of Distinct Elements

Unique Product of Distinct Elements

You are given T test cases. For each test case, a list of N integers is provided. Your task is to compute the product of all distinct integers in the list. If the list is empty (i.e. N = 0) or if the only distinct element is \(1\), output \(1\).

For each test case, read the input from standard input and output the result to standard output on a new line.

inputFormat

The first line contains an integer \(T\), the number of test cases.

Each test case is described in two lines:

  • The first line contains an integer \(N\), the number of integers in the test case.
  • The second line contains \(N\) space-separated integers.

outputFormat

For each test case, output a single integer on a new line, representing the product of all distinct elements in the list. If the test case has no integers (i.e. \(N=0\)) or if the only distinct element is \(1\), output \(1\).

## sample
3
4 2 3 2 4
5 1 2 3 4 5
3 1 1 1
24

120 1

</p>