codeforces-scrape

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

317A.md (1966B)


      1 Source: https://codeforces.com/problemset/problem/317/A
      2 
      3 A. Perfect Pair
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Let us call a pair of integer numbers *m*-perfect, if at least one number in the pair is greater than or equal to *m*. Thus, the pairs (3, 3) and (0, 2) are 2-perfect while the pair (-1, 1) is not.
     22 
     23 Two integers *x*, *y* are written on the blackboard. It is allowed to erase one of them and replace it with the sum of the numbers, (*x* + *y*).
     24 
     25 What is the minimum number of such operations one has to perform in order to make the given pair of integers *m*-perfect?
     26 
     27 Input
     28 
     29 Single line of the input contains three integers *x*, *y* and *m* ( - 1018 ≤ *x*, *y*, *m* ≤ 1018).
     30 
     31 Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preffered to use the cin, cout streams or the %I64d specifier.
     32 
     33 Output
     34 
     35 Print the minimum number of operations or "-1" (without quotes), if it is impossible to transform the given pair to the *m*-perfect one.
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 1 2 5
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 2
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 -1 4 15
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 4
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 0 -1 5
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 -1
     73 ```
     74 
     75 Note
     76 
     77 In the first sample the following sequence of operations is suitable: (1, 2) ![](https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png) (3, 2) ![](https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png) (5, 2).
     78 
     79 In the second sample: (-1, 4) ![](https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png) (3, 4) ![](https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png) (7, 4) ![](https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png) (11, 4) ![](https://espresso.codeforces.com/70a0795f45d32287dba0eb83fc4a3f470c6e5537.png) (15, 4).
     80 
     81 Finally, in the third sample *x*, *y* cannot be made positive, hence there is no proper sequence of operations.