4586 J

时间限制1 S
内存限制128 MB
通过率12.5%(5 / 40)
题目描述
虽然杰瑞是一只老鼠,但他喜欢完美的平方数。如果一个数字可以表示为整数的平方,则称为完全平方数。杰瑞可以使用魔法向前或向后移动任何完美平方数的距离,每次都要花费一粒米。并且每次使用魔法后的位置不能在初始位置后面或超过初始位置前方105距离。接下来,有q问题,每次问杰瑞至少需要多少米才能前进di。请注意,每个问题都是独立的问题。
输入格式

The first line contains an integer q(1 ≤ q ≤ 100000) ,which represents the number of questions you need to solve.

Each of the next q lines contains an integer di(1 ≤ di ≤ 100000),which represents the distance Jerry want to move forward

输出格式
For each query, print an integer to represent the minimum cost of rice.
输入输出样例
输入复制
2
8
7
输出复制
2
2
数据范围与提示

In the first query: 0 -> 4 -> 8.

In the second query: 0 -> 16 -> 7;

上传者
提交记录查看记录
题目类型传统
评测方式Special Judge
提交 / 通过40 / 5
相关讨论
暂无讨论