当前位置: 代码迷 >> 综合 >> Jumping Jack(翻译)
  详细解决方案

Jumping Jack(翻译)

热度:3   发布时间:2023-12-05 14:31:12.0

2022.2.18

题目网址:

https://codeforces.com/contest/11/problem/B

题目:

Jumping Jack

 1000ms  65536K

描述:

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.

输入:

The input data consists of only one integer x (?-?109?≤?x?≤?109).

输出:

Output the minimal number of jumps that Jack requires to reach x.

翻译:

描述:

杰克最近正在致力于他的跳跃技巧。现在他位于数字为0的一点。他想要到点x。为了到那里,他已经决定他第一次跳跃只是一个单位,并且每个跳跃将比前一个跳跃更长。他只能向左或者向右跳跃。他想知道是需要多少跳跃才能到达点x。

输入:

输入数据包含一个整数x(-109<=x<=109)。

输出:

输出杰克到达x需要的最少的跳跃次数。

  相关解决方案