194B.md (1695B)
1 Source: https://codeforces.com/problemset/problem/194/B 2 3 B. Square 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 stdin 16 17 output 18 19 stdout 20 21 There is a square painted on a piece of paper, the square's side equals *n* meters. John Doe draws crosses on the square's perimeter. John paints the first cross in the lower left corner of the square. Then John moves along the square's perimeter in the clockwise direction (first upwards, then to the right, then downwards, then to the left and so on). Every time he walks (*n* + 1) meters, he draws a cross (see picture for clarifications). 22 23 John Doe stops only when the lower left corner of the square has two crosses. How many crosses will John draw? 24 25  The figure shows the order in which John draws crosses for a square with side 4. The lower left square has two crosses. Overall John paints 17 crosses. 26 27 Input 28 29 The first line contains integer *t* (1 ≤ *t* ≤ 104) — the number of test cases. 30 31 The second line contains *t* space-separated integers *n**i* (1 ≤ *n**i* ≤ 109) — the sides of the square for each test sample. 32 33 Output 34 35 For each test sample print on a single line the answer to it, that is, the number of crosses John will draw as he will move along the square of the corresponding size. Print the answers to the samples in the order in which the samples are given in the input. 36 37 Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. 38 39 Examples 40 41 Input 42 43 ``` 44 3 45 4 8 100 46 ``` 47 48 Output 49 50 ``` 51 17 52 33 53 401 54 ```