codeforces-scrape

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

652A.md (2166B)


      1 Source: https://codeforces.com/problemset/problem/652/A
      2 
      3 A. Gabriel and Caterpillar
      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 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 The 9-th grade student Gabriel noticed a caterpillar on a tree when walking around in a forest after the classes. The caterpillar was on the height *h*1 cm from the ground. On the height *h*2 cm (*h*2 > *h*1) on the same tree hung an apple and the caterpillar was crawling to the apple.
     22 
     23 Gabriel is interested when the caterpillar gets the apple. He noted that the caterpillar goes up by *a* cm per hour by day and slips down by *b* cm per hour by night.
     24 
     25 In how many days Gabriel should return to the forest to see the caterpillar get the apple. You can consider that the day starts at 10 am and finishes at 10 pm. Gabriel's classes finish at 2 pm. You can consider that Gabriel noticed the caterpillar just after the classes at 2 pm.
     26 
     27 Note that the forest is magic so the caterpillar can slip down under the ground and then lift to the apple.
     28 
     29 Input
     30 
     31 The first line contains two integers *h*1, *h*2 (1 ≤ *h*1 < *h*2 ≤ 105) — the heights of the position of the caterpillar and the apple in centimeters.
     32 
     33 The second line contains two integers *a*, *b* (1 ≤ *a*, *b* ≤ 105) — the distance the caterpillar goes up by day and slips down by night, in centimeters per hour.
     34 
     35 Output
     36 
     37 Print the only integer *k* — the number of days Gabriel should wait to return to the forest and see the caterpillar getting the apple.
     38 
     39 If the caterpillar can't get the apple print the only integer  - 1.
     40 
     41 Examples
     42 
     43 Input
     44 
     45 ```
     46 10 30  
     47 2 1
     48 ```
     49 
     50 Output
     51 
     52 ```
     53 1
     54 ```
     55 
     56 Input
     57 
     58 ```
     59 10 13  
     60 1 1
     61 ```
     62 
     63 Output
     64 
     65 ```
     66 0
     67 ```
     68 
     69 Input
     70 
     71 ```
     72 10 19  
     73 1 2
     74 ```
     75 
     76 Output
     77 
     78 ```
     79 -1
     80 ```
     81 
     82 Input
     83 
     84 ```
     85 1 50  
     86 5 4
     87 ```
     88 
     89 Output
     90 
     91 ```
     92 1
     93 ```
     94 
     95 Note
     96 
     97 In the first example at 10 pm of the first day the caterpillar gets the height 26. At 10 am of the next day it slips down to the height 14. And finally at 6 pm of the same day the caterpillar gets the apple.
     98 
     99 Note that in the last example the caterpillar was slipping down under the ground and getting the apple on the next day.