codeforces-scrape

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

712C.md (1927B)


      1 Source: https://codeforces.com/problemset/problem/712/C
      2 
      3 C. Memory and De-Evolution
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Memory is now interested in the de-evolution of objects, specifically triangles. He starts with an equilateral triangle of side length *x*, and he wishes to perform operations to obtain an equilateral triangle of side length *y*.
     22 
     23 In a single second, he can modify the length of a single side of the current triangle such that it remains a non-degenerate triangle (triangle of positive area). At any moment of time, the length of each side should be integer.
     24 
     25 What is the minimum number of seconds required for Memory to obtain the equilateral triangle of side length *y*?
     26 
     27 Input
     28 
     29 The first and only line contains two integers *x* and *y* (3 ≤ *y* < *x* ≤ 100 000) — the starting and ending equilateral triangle side lengths respectively.
     30 
     31 Output
     32 
     33 Print a single integer — the minimum number of seconds required for Memory to obtain the equilateral triangle of side length *y* if he starts with the equilateral triangle of side length *x*.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 6 3
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 4
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 8 5
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 3
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 22 4
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 6
     71 ```
     72 
     73 Note
     74 
     75 In the first sample test, Memory starts with an equilateral triangle of side length 6 and wants one of side length 3. Denote a triangle with sides *a*, *b*, and *c* as (*a*, *b*, *c*). Then, Memory can do ![](https://espresso.codeforces.com/18af21f738bad490df83097a90e1f2879a4b21c6.png).
     76 
     77 In the second sample test, Memory can do ![](https://espresso.codeforces.com/bcfd51d1b2d764a1cf5fbc255cc02e6f5aaed3b1.png).
     78 
     79 In the third sample test, Memory can do: ![](https://espresso.codeforces.com/0969b7d413854c1e7528991d926bef1f7ffba008.png)
     80 
     81 ![](https://espresso.codeforces.com/63e9e66b882c03e4c73e93ad92204dc255329309.png).