Problem 3825 --Jerry

3825: Jerry

"
Time Limit $1$ 秒/Second(s) Memory Limit $128$ 兆字节/Megabyte(s)
提交总数 $11$ 正确数量 $3$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
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 105 distance in front of the initial position. Next, there are  q  questions, each time asking how much rice at least it takes for Jerry to move forward di. Note that each question is an independent one.

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.

推荐代码 查看3825 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$66 $ms] 只能过个样例~~~ 762303 2021-09-01 19:52:29
内存最少[$2868 $KB] 只能过个样例~~~ 762303 2021-09-01 19:52:29
第一AC 只能过个样例~~~ 762303 2021-09-01 19:52:29
第一挑战 只能过个样例~~~ 762303 2021-09-01 19:52:29

赛题来源/所属竞赛 2021GDCPC N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛