codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

11B.md (852B)


      1 Source: https://codeforces.com/problemset/problem/11/B
      2 
      3 B. Jumping Jack
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 64 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 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*.
     22 
     23 Input
     24 
     25 The input data consists of only one integer *x* ( - 109 ≤ *x* ≤ 109).
     26 
     27 Output
     28 
     29 Output the minimal number of jumps that Jack requires to reach *x*.
     30 
     31 Examples
     32 
     33 Input
     34 
     35 ```
     36 2
     37 ```
     38 
     39 Output
     40 
     41 ```
     42 3
     43 ```
     44 
     45 Input
     46 
     47 ```
     48 6
     49 ```
     50 
     51 Output
     52 
     53 ```
     54 3
     55 ```
     56 
     57 Input
     58 
     59 ```
     60 0
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 0
     67 ```