poj3475

简单题

View Code
#include <iostream>
#include
<cstdlib>
#include
<cstring>
#include
<cstdio>
using namespace std;

#define eps 1.0e-8

int work(double a, double b, double c, double d)
{
int ret = 0;
while (c > a + eps)
{
ret
++;
c
/= 2;
}
while (d > b + eps)
{
ret
++;
d
/= 2;
}
return ret;
}

int main()
{
//freopen("D:\\t.txt", "r", stdin);
int a, b, c, d;
while (scanf("%d%d%d%d", &a, &b, &c, &d) != EOF)
{
int ans1 = work(a, b, c, d);
int ans2 = work(b, a, c, d);
int ans = min(ans1, ans2);
printf(
"%d\n", ans);
}
return 0;
}
posted @ 2011-05-01 12:46  金海峰  阅读(157)  评论(0编辑  收藏  举报