cswork / OA打开练习工作台

SalesforceOA #8

Count Minimum Operations to Reduce Dimensions

估计中等可在线判题

考点(AI 标注)位运算贪心调度

Each fold is made along a crease parallel to one side and need not be in the middle; it changes only the corresponding dimension, and the target size is not rotated. One fold can turn a length L into any length in [L/2,L). Find the minimum number of folds needed to reach exactly h1,w1.

输入格式

One line with h w h1 w1. The original text guarantees h1≤h and w1≤w and gives no numeric upper bound; on this site all four are integers in 1..10⁹.

输出格式

Output the minimum number of folds.

样例 1

输入:

8 4 6 1

输出:

3

样例 2

输入:

5 7 5 7

输出:

0

样例 3

输入:

9 9 1 1

输出:

8

样例说明

The answers are 3, 0, and 8; in the first example, height 8 can be folded to 6 in one fold, so folds must not be restricted to folding exactly in half.