No.1010 Fold and Stack
Problem Statement
There is a sheet of paper with a width of $x$ m, a height of $y$ m, and a thickness of $h$ mm.
Consider folding this paper in half. Folding the paper refers to the following two kinds of operations.
・If the width is greater than the thickness, halve the width and double the thickness.
・If the height is greater than the thickness, halve the height and double the thickness.
The operations may be performed in any order. Find the maximum number of times the paper can be folded.
* Note that the units of the width and height differ from the unit of the thickness.
Input
$x\ y\ h$
All inputs are given as integers.
$1\le x,y \le 10^9$
$1 \le h \le 1000$
Output
Output the maximum number of times the paper can be folded.
Print a newline at the end.
Sample
Sample 1
Input
2 4 1000
Output
2
First, fold along the width; the width of the paper becomes 1 m and the thickness becomes 2 m.
At this point, the height is greater than the thickness, so folding along the height makes the height 2 m and the thickness 4 m.
With this procedure, the paper can be folded 2 times.
If you fold along the height first, the paper cannot be folded any further, so this paper can be folded at most 2 times.
Sample 2
Input
1 1 1
Output
8
The paper can be folded at most 8 times.
Sample 3
Input
3 1 5
Output
7
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
otamay6
leafirby