CF 1809B - Points on Plane
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 than1, and the cost is the minimum possible.
Input
The first line contains one integer t (1≤t≤104) — the number of test cases. Next t cases follow.
The first and only line of each test case contains one integer n
?(1≤n≤1018) — 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.
-------------------------------------
給你一個二維平面,你需要在上面放置 n 個芯片。
您只能將芯片放置在具有整數(shù)坐標的點上。 將籌碼放置在點 (x,y) 的成本等于 |x|+|y| (其中 |a|
? 是 a) 的絕對值。
放置n個芯片的成本等于每個芯片成本中的最大值。
你需要將n個芯片放置在平面上,使得每對芯片之間的歐氏距離嚴格大于1,并且成本盡可能最小。
輸入
第一行包含一個整數(shù) t (1≤t≤104) — 測試用例的數(shù)量。 接下來是t個案例。
每個測試用例的第一行也是唯一一行包含一個整數(shù) n
? (1≤n≤1018) — 您需要放置的芯片數(shù)量。
輸出
對于每個測試用例,打印一個整數(shù) - 如果每對芯片之間的距離必須嚴格大于 1,則放置 n 個芯片的最小成本。
------------------------------
我們舉個例子;
如果是5-9個就需要2個。
如果是10-16個就需要4個。
如果是n個,那么就看n的平方根正好是整數(shù)不是,如果是,--,如果不是,+1,然后輸出這個數(shù)-1的數(shù)。
有點繞啊。。我是越來越看不懂了。