311386: CF1979C. Earning on Bets

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Earning on Betstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

You have been offered to play a game. In this game, there are $n$ possible outcomes, and for each of them, you must bet a certain integer amount of coins. In the event that the $i$-th outcome turns out to be winning, you will receive back the amount of coins equal to your bet on that outcome, multiplied by $k_i$. Note that exactly one of the $n$ outcomes will be winning.

Your task is to determine how to distribute the coins in such a way that you will come out ahead in the event of any winning outcome. More formally, the total amount of coins you bet on all outcomes must be strictly less than the number of coins received back for each possible winning outcome.

Input

Each test consists of multiple test cases. The first line contains a single 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 a single integer $n$ ($1 \le n \le 50$) — the number of outcomes.

The second line of each test case contains $n$ integers $k_1,k_2,\ldots,k_n$ ($2 \le k_i \le 20$) — the multiplier for the amount of coins if the $i$-th outcome turns out to be winning.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

Output

For each test case, output $-1$ if there is no way to distribute the coins as required. Otherwise, output $n$ integers $x_1, x_2,\ldots, x_n$ ($1 \le x_i \le 10^{9}$) — your bets on the outcomes.

It can be shown that if a solution exists, there is always a solution that satisfies these constraints.

If there are multiple suitable solutions, output any of them.

ExampleInput
6
3
3 2 7
2
3 3
5
5 5 5 5 5
6
7 9 3 17 9 13
3
6 3 2
5
9 4 6 8 3
Output
27 41 12 
1 1 
-1
1989 1547 4641 819 1547 1071 
-1
8 18 12 9 24
Note

In the first test case, the coins can be distributed as follows: $27$ coins on the first outcome, $41$ coins on the second outcome, $12$ coins on the third outcome. Then the total amount of coins bet on all outcomes is $27 + 41 + 12 = 80$ coins. If the first outcome turns out to be winning, you will receive back $3 \cdot 27 = 81$ coins, if the second outcome turns out to be winning, you will receive back $2 \cdot 41 = 82$ coins, if the third outcome turns out to be winning, you will receive back $7 \cdot 12 = 84$ coins. All these values are strictly greater than $80$.

In the second test case, one way is to bet one coin on each of the outcomes.

Output

题目大意:
这个题目是关于如何在不同结果上分配投注以便在任何一个结果胜出时都能获得盈利。有 n 个可能的结果,每个结果都有一个对应的倍数 k_i,表示如果这个结果赢了你将获得你在这个结果上投注的硬币数乘以 k_i。你必须确保在所有结果上的总投注严格小于在任何可能赢的结果上能收回的硬币数。

输入数据格式:
输入包含多个测试用例。第一行包含一个整数 t(1 ≤ t ≤ 10^4),表示测试用例的数量。接下来是每个测试用例的描述。
每个测试用例的第一行包含一个整数 n(1 ≤ n ≤ 50),表示结果的数量。
第二行包含 n 个整数 k_1, k_2, ..., k_n(2 ≤ k_i ≤ 20),表示每个结果的倍数。
保证所有测试用例中 n 的总和不超过 2 × 10^5。

输出数据格式:
对于每个测试用例,如果不存在满足条件的硬币分配方式,则输出 -1。否则,输出 n 个整数 x_1, x_2, ..., x_n(1 ≤ x_i ≤ 10^9),表示你在每个结果上的投注。如果有多种合适的方案,输出其中任意一种。

请注意,这里使用了 LaTeX 格式来表示数学公式中的整数(\textbf{integer})和加粗文本。题目大意: 这个题目是关于如何在不同结果上分配投注以便在任何一个结果胜出时都能获得盈利。有 n 个可能的结果,每个结果都有一个对应的倍数 k_i,表示如果这个结果赢了你将获得你在这个结果上投注的硬币数乘以 k_i。你必须确保在所有结果上的总投注严格小于在任何可能赢的结果上能收回的硬币数。 输入数据格式: 输入包含多个测试用例。第一行包含一个整数 t(1 ≤ t ≤ 10^4),表示测试用例的数量。接下来是每个测试用例的描述。 每个测试用例的第一行包含一个整数 n(1 ≤ n ≤ 50),表示结果的数量。 第二行包含 n 个整数 k_1, k_2, ..., k_n(2 ≤ k_i ≤ 20),表示每个结果的倍数。 保证所有测试用例中 n 的总和不超过 2 × 10^5。 输出数据格式: 对于每个测试用例,如果不存在满足条件的硬币分配方式,则输出 -1。否则,输出 n 个整数 x_1, x_2, ..., x_n(1 ≤ x_i ≤ 10^9),表示你在每个结果上的投注。如果有多种合适的方案,输出其中任意一种。 请注意,这里使用了 LaTeX 格式来表示数学公式中的整数(\textbf{integer})和加粗文本。

加入题单

上一题 下一题 算法标签: