CF1809B.Points on Plane
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
给你一个二维平面,你需要在平面上放置 n 个芯片。
你只能将芯片放置在整数坐标点上。在点 (x,y) 处放置一个芯片的代价为 ∣x∣+∣y∣(其中 ∣a∣ 表示 a 的绝对值)。
放置 n 个芯片的总代价定义为所有芯片代价中的最大值。
你需要在平面上放置 n 个芯片,使得任意两个芯片之间的欧几里得距离严格大于 1,且总代价尽可能小。
输入格式
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.
第一行包含一个整数 t(1≤t≤104)—— 测试用例的数量。接下来是 t 个测试用例。
每个测试用例仅有一行,包含一个整数 n(1≤n≤1018)—— 你需要放置的芯片数量。
输出格式
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.
对于每个测试用例,输出一个整数——在每对芯片之间的距离严格大于 1 的前提下,放置 n 个芯片的最小代价。
输入输出样例
输入#1
4 1 3 5 975461057789971042
输出#1
0 1 2 987654321
说明/提示
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 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.
在第一个测试用例中,你可以将唯一的芯片放置在点 (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。
输入解题思路,AI测评打分。不知道怎么写?