luogu#P7036. [NWRRC2016] Folding

[NWRRC2016] Folding

题目描述

As you can remember, Alex is fond of origami. She switched from squares to rectangles, and rectangles are much more difficult to master. Her main interest is to determine what is the minimum possible number of folds required to transform W×HW \times H rectangle to w×hw \times h one. The result of each fold should also be rectangular, so it is only allowed to make folds that are parallel to the sides of the rectangle.

Help Alex and write a program that determines the minimum required number of folds.

输入格式

The first line of the input contains two integers WW and HH -- the initial rectangle dimensions. The second line contains two more integers ww and hh -- the target rectangle dimensions (1W,H,w,h109).(1 \le W , H , w , h \le 10^{9}).

输出格式

Output a single integer -- the minimum required number of folds to transform the initial rectangle to the target one.

If the required transformation is not possible, output 1−1 .

题目大意

题目大意:

求一个 W×HW\times H 的矩形通过折叠变为一个 w×hw\times h 的矩形的最少折叠次数,其中每次折叠的折痕必须平行于矩形的一边。


输入格式:

第一行两个正整数 W,HW,H,第二行两个正整数 w,hw,h

1W,H,w,h1091\le W,H,w,h\le10^9


输出格式:

输出最少折叠次数。若无法通过折叠变为目标矩形,输出 -1

2 7
2 2

2

10 6
4 8

2

5 5
1 6

-1

提示

Time limit: 2 s, Memory limit: 256 MB.