1463B.md (1411B)
1 Source: https://codeforces.com/problemset/problem/1463/B 2 3 B. Find The Array 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 You are given an array $[a_1, a_2, \dots, a_n]$ such that $1 \le a_i \le 10^9$. Let $S$ be the sum of all elements of the array $a$. 22 23 Let's call an array $b$ of $n$ integers beautiful if: 24 25 * $1 \le b_i \le 10^9$ for each $i$ from $1$ to $n$; 26 * for every pair of adjacent integers from the array $(b_i, b_{i + 1})$, either $b_i$ divides $b_{i + 1}$, or $b_{i + 1}$ divides $b_i$ (or both); 27 * $2 \sum \limits_{i = 1}^{n} |a_i - b_i| \le S$. 28 29 Your task is to find any beautiful array. It can be shown that at least one beautiful array always exists. 30 31 Input 32 33 The first line contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases. 34 35 Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 50$). 36 37 The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$). 38 39 Output 40 41 For each test case, print the beautiful array $b_1, b_2, \dots, b_n$ ($1 \le b_i \le 10^9$) on a separate line. It can be shown that at least one beautiful array exists under these circumstances. If there are multiple answers, print any of them. 42 43 Example 44 45 Input 46 47 ``` 48 4 49 5 50 1 2 3 4 5 51 2 52 4 6 53 2 54 1 1000000000 55 6 56 3 4 8 1 2 3 57 ``` 58 59 Output 60 61 ``` 62 3 3 3 3 3 63 3 6 64 1 1000000000 65 4 4 8 1 3 3 66 ```