310280: CF1809B. Points on Plane

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Points on Planetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given a two-dimensional plane, and you need to place $n$ chips on it.

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$).

The cost of placing $n$ chips is equal to the maximum among the costs of each chip.

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.

Input

The first line contains one integer $t$ ($1 \le t \le 10^4$) — the number of test cases. Next $t$ cases follow.

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.

Output

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$.

ExampleInput
4
1
3
5
975461057789971042
Output
0
1
2
987654321
Note

In the first test case, you can place the only chip at point $(0, 0)$ with total cost equal to $0 + 0 = 0$.

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$.

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$.

Input

题意翻译

# 平面上的点 ## 描述 给你一个二维平面,你需要在其上放置 $n$ 个棋子。 你只能将棋子放在整数坐标的点上。将棋子放在坐标点 $ (x, y) $ 上的成本等于 $ |x| + |y| $ (其中,$|a|$ 表示 $a$ 的绝对值)。 放置 $n$ 个棋子的成本等于其中最大的单个棋子的成本。 你需要在平面上布置 $n$ 个棋子,使得每对棋子之间的欧几里得距离严格大于 $1$ ,且成本尽可能小。 ## 输入 第一行包含一个整数 $t$($1 \leq t \leq 10^4$),表示测试数据组数。接下来 $t$ 行,每行包含一个整数 $n$ ($1 \leq n \leq 10^{18}$),表示需要放置的棋子数量。 ## 输出 对于每个测试用例,输出一个整数,表示在每对棋子之间的距离都必须严格大于 $1$ 的情况下放置 $n$ 个棋子的最小成本。 ## 提示 在第一个测试用例中,你可以把唯一的棋子放在坐标 $ (0, 0) $ 上,总成本为 $ 0 + 0 = 0 $。 在第二个测试用例中,你可以将棋子放在 $ (-1, 0) $,$ (0, 1) $ 和 $ (1, 0) $ 上,成本分别为 $ |-1| + |0| = 1 $,$ |0| + |1| = 1 $ 和 $ |0| + |1| = 1 $。每对棋子之间的距离严格大于 $1$(例如,$(-1,0)$ 和 $ (0,1) $之间的距离等于 $ \sqrt{2} $)。总成本等于 $ \max(1,1,1)=1 $。 在第三个测试用例中,你可以将棋子放在 $ (-1,-1) $,$ (-1,1) $,$ (1,1) $,$ (0,0) $ 和 $ (0,2) $ 上。总成本等于 $ \max(2, 2, 2, 0, 2) = 2 $。

Output

题目大意:
在二维平面上放置n个筹码。筹码只能放在整数坐标点上。在点(x, y)放置一个筹码的成本是|x| + |y|(|a|表示a的绝对值)。放置n个筹码的总成本是每个筹码成本中的最大值。需要以这样的方式放置n个筹码:每对筹码之间的欧几里得距离严格大于1,且成本尽可能小。

输入数据格式:
第一行包含一个整数t(1 ≤ t ≤ 10^4)——测试用例的数量。接下来是t个测试用例。
每个测试用例的第一行包含一个整数n(1 ≤ n ≤ 10^18)——需要放置的筹码数量。

输出数据格式:
对于每个测试用例,打印一个整数——在每对筹码之间的距离严格大于1的条件下,放置n个筹码的最小成本。

例:
输入
```
4
1
3
5
975461057789971042
```
输出
```
0
1
2
987654321
```

注意:
- 在第一个测试用例中,可以在点(0, 0)放置唯一一个筹码,总成本为0 + 0 = 0。
- 在第二个测试用例中,例如,可以在点(-1, 0)、(0, 1)和(1, 0)放置筹码,成本分别为|-1| + |0| = 1、|0| + |1| = 1和|0| + |1| = 1。每对筹码之间的距离大于1(例如,(-1, 0)和(0, 1)之间的距离为√2)。总成本为max(1, 1, 1) = 1。
- 在第三个测试用例中,例如,可以在点(-1, -1)、(-1, 1)、(1, 1)、(0, 0)和(0, 2)放置筹码。总成本为max(2, 2, 2, 0, 2) = 2。题目大意: 在二维平面上放置n个筹码。筹码只能放在整数坐标点上。在点(x, y)放置一个筹码的成本是|x| + |y|(|a|表示a的绝对值)。放置n个筹码的总成本是每个筹码成本中的最大值。需要以这样的方式放置n个筹码:每对筹码之间的欧几里得距离严格大于1,且成本尽可能小。 输入数据格式: 第一行包含一个整数t(1 ≤ t ≤ 10^4)——测试用例的数量。接下来是t个测试用例。 每个测试用例的第一行包含一个整数n(1 ≤ n ≤ 10^18)——需要放置的筹码数量。 输出数据格式: 对于每个测试用例,打印一个整数——在每对筹码之间的距离严格大于1的条件下,放置n个筹码的最小成本。 例: 输入 ``` 4 1 3 5 975461057789971042 ``` 输出 ``` 0 1 2 987654321 ``` 注意: - 在第一个测试用例中,可以在点(0, 0)放置唯一一个筹码,总成本为0 + 0 = 0。 - 在第二个测试用例中,例如,可以在点(-1, 0)、(0, 1)和(1, 0)放置筹码,成本分别为|-1| + |0| = 1、|0| + |1| = 1和|0| + |1| = 1。每对筹码之间的距离大于1(例如,(-1, 0)和(0, 1)之间的距离为√2)。总成本为max(1, 1, 1) = 1。 - 在第三个测试用例中,例如,可以在点(-1, -1)、(-1, 1)、(1, 1)、(0, 0)和(0, 2)放置筹码。总成本为max(2, 2, 2, 0, 2) = 2。

加入题单

算法标签: