Professional Documents
Culture Documents
Shahid has created a complex machine that takes in a sequence A = [A1 , A2 , … , AN ] and
produces a sequence B = [B1 , B2 , … , BN ] such that for each valid i, Bi is the largest index j
such that Aj divides Ai (including itself). For instance, if the input sequence is A = [2, 6, 3, 12],
Input
Output
For each test case, print N space-separated integers representing Ai . For each valid i, 1
≤ Ai ≤
If there are multiple solutions, you may print any of them. It is guaranteed that at least one
solution exists.
Constraints
1 ≤ T ≤ 2 ⋅ 104
1 ≤ N ≤ 105
1 ≤ Bi ≤ N for each valid i
the sum of N over all test cases does not exceed 2 ⋅ 105
Sample 1
-
Coderun 04 - The Revival Mar 14, 2023
Input Output
2 3 5 7 4 10
5 2 3 8 9
1 5 3 4 5
4
3 4 3 4