Logo
(追記) (追記ここまで)

13478번 - Folding 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB256979239.827%

문제

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 × H rectangle to w × 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 W and H — the initial rectangle dimensions. The second line contains two more integers w and h — the target rectangle dimensions (1 ≤ W, H, w, h ≤ 109).

출력

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

2 7
2 2

예제 출력 1

2

예제 입력 2

10 6
4 8

예제 출력 2

2

예제 입력 3

5 5
1 6

예제 출력 3

-1

힌트

In the first example you should fold 2 × 7 rectangle to 2 × 4, and then to 2 × 2.

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > NEERC Northern Subregional 2016 F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /