| Codeforces Round 1076 (Div. 3) |
|---|
| Finished |
Today, Sabyrzhan was called to the board with an array $$$a$$$ of length $$$n$$$ and was assigned an officer's task — to answer $$$n$$$ questions.
In the $$$i$$$-th question, it is required to determine the minimum number of elements from the array that need to be selected from the board (it is allowed to use the same element multiple times) so that their product is exactly equal to $$$i$$$, or to report that it is impossible to achieve such a product.
Note that at least one element must be selected.
Each test consists of several test cases. The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. The description of the test cases follows.
The first line of each test case contains one integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10 ^ 5$$$).
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$).
It is guaranteed that the sum of the values of $$$n$$$ across all test cases does not exceed $$$3 \cdot 10 ^ 5$$$.
For the $$$i$$$-th question, output one integer — the minimum number of elements from the array required to obtain a product equal to $$$i$$$, or $$$−1$$$ if it is impossible to achieve such a product.
683 2 2 3 7 3 6 751 2 3 4 531 1 1102 1 2 1 3 5 5 7 7 741 1 2 211
-1 1 1 2 -1 1 1 31 1 1 1 11 -1 -11 1 1 2 1 2 1 3 2 21 1 -1 21
Consider the first test case. The products can be obtained as follows:
| Name |
|---|


