Although Jerry is a mouse, he likes perfect square numbers. If a number can be expressed as the square of an integer, it is called perfect square numbers. Jerry can use magic to move forward or backward a distance of any perfect square numbers, which costs a grain of rice each time. And the position after each use of magic can not be behind the initial position or more than
distance in front of the initial position. Next, there are
questions, each time asking how much rice at least it takes for Jerry to move forward
.Note that each question is an independent one.
输入描述:
The first line contains an integer
,which represents the number of questions you need to solve.
Each of the next
lines contains an integer
,which represents the distance Jerry want to move forward.
输出描述:
For each query, print an integer to represent the minimum cost of rice.
示例1
说明
In the first query: 0 -> 4 -> 8.
In the second query: 0 -> 16 -> 7.