Jumping Jack | ||||||
| ||||||
Description | ||||||
Jack is working on his jumping skills recently. Currently he's located at point zero of the number line. He would like to get to the point x. In order to train, he has decided that he'll first jump by only one unit, and each subsequent jump will be exactly one longer than the previous one. He can go either left or right with each jump. He wonders how many jumps he needs to reach x. | ||||||
Input | ||||||
For each test case: | ||||||
Output | ||||||
For each test case: | ||||||
Sample Input | ||||||
2 | ||||||
Sample Output | ||||||
3 想要用的步数最少,肯定就是往一个方向走到头,然后画图发现从(end - start) % 2 = 0处便可以往回走
|
Hust oj 1071 Jumping Jack(贪心)
最新推荐文章于 2022-11-21 21:55:25 发布