1809B.md (1884B)
1 Source: https://codeforces.com/problemset/problem/1809/B 2 3 B. Points on Plane 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 a two-dimensional plane, and you need to place $n$ chips on it. 22 23 You can place a chip only at a point with integer coordinates. The cost of placing a chip at the point $(x, y)$ is equal to $|x| + |y|$ (where $|a|$ is the absolute value of $a$). 24 25 The cost of placing $n$ chips is equal to the maximum among the costs of each chip. 26 27 You need to place $n$ chips on the plane in such a way that the Euclidean distance between each pair of chips is strictly greater than $1$, and the cost is the minimum possible. 28 29 Input 30 31 The first line contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases. Next $t$ cases follow. 32 33 The first and only line of each test case contains one integer $n$ ($1 \le n \le 10^{18}$) — the number of chips you need to place. 34 35 Output 36 37 For each test case, print a single integer — the minimum cost to place $n$ chips if the distance between each pair of chips must be strictly greater than $1$. 38 39 Example 40 41 Input 42 43 ``` 44 4 45 46 1 47 48 3 49 50 5 51 52 975461057789971042 53 ``` 54 55 Output 56 57 ``` 58 0 59 1 60 2 61 987654321 62 ``` 63 64 Note 65 66 In the first test case, you can place the only chip at point $(0, 0)$ with total cost equal to $0 + 0 = 0$. 67 68 In the second test case, you can, for example, place chips at points $(-1, 0)$, $(0, 1)$ and $(1, 0)$ with costs $|-1| + |0| = 1$, $|0| + |1| = 1$ and $|0| + |1| = 1$. Distance between each pair of chips is greater than $1$ (for example, distance between $(-1, 0)$ and $(0, 1)$ is equal to $\sqrt{2}$). The total cost is equal to $\max(1, 1, 1) = 1$. 69 70 In the third test case, you can, for example, place chips at points $(-1, -1)$, $(-1, 1)$, $(1, 1)$, $(0, 0)$ and $(0, 2)$. The total cost is equal to $\max(2, 2, 2, 0, 2) = 2$.