1731. Inversion

时间限制 2000 ms   内存限制 64 MB

Give an array A, the index starts from 1.
Now we want to know $B_{i}= \max\limits_{i\nmid j}A_{j} $ , $i \geq 2$.

输入数据

The first line of the input gives the number of test cases T; T test cases follow.
Each case begins with one line with one integer n : the size of array A.
Next one line contains n integers, separated by space, ith number is $A_{i}$.

Limits
$T \leq 20$
$2 \leq n \leq 100000$
$1 \leq Ai \leq 1000000000$
$\sum{n} \leq 700000$

输出数据

For each test case output one line contains n-1 integers, separated by space, ith number is $B_{i+1}$.

样例输入

复制
2
4
1 2 3 4
4
1 4 2 3 \n
 \n
 · · · \n
 \n
 · · · \n

样例输出

复制
3 4 3
2 4 4 · · \n
 · · \n

提交

请先 登录

Source

2017 Multi-University Training Contest - Team 6

© 2024 FAQs Contact About