2013
11-12

# Paper-, er, Transcript-Folding Game

To help you better understand frkstyc’s experience folding his transcripts, consider this problem: given the dimensions of an envelop and a transcript, how many times does the transcript have to be folded until its dimensions do not exceed those of the envelop? Remember that frkstyc was preparing the transcripts for the review of faculty members in admission commitees, which required him to fold the transcripts either horizontally or vertically each time, halving its size. Additionally, the transcript must not lie slanted in the envelop.

The input contains multiple test cases each occupying one line. Each test case consists of four integers a, b, c, d (0 < a, b, c, d ≤ 231 − 1) indicating that the dimension of an envelop is a × b and that of a transcript is c × d. Process until EOF is met.

For each test case, output the minimum number of times a transcript has to be folded.

1 2 1 4
2 1 1 4

1
1

//* @author: Yeming Hu"[email protected]/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */"
import java.util.*;

public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
while(sc.hasNext())
{
long a = sc.nextLong();
long b = sc.nextLong();
double c = sc.nextDouble();
double d = sc.nextDouble();
int steps = 0;
if(a > b)
{
long temp = a;
a = b;
b = temp;
}
while(true)
{
if(c > d)
{
double temp = c;
c = d;
d = temp;
}

if(a >= c && b >=d)
{
break;
}else if(b < d)
{
d = d/2;
steps++;
}else
{
c = c/2;
steps++;
}
}
System.out.println(steps);
}
}
}