include iostream include cmath include algorithm using namespace std i

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
int h, w, m, n, cnt = 0, v1, n1, m1;
cin >> n >> m >> h >> w;
n1 = n;
m1 = m;
while(h - m < 0) {
m = ceil((float)m / 2.0);
cnt++;
}
while(w - n < 0){
n = ceil((float)n / 2.0);
cnt++;
}
v1 = cnt;
cnt = 0;
n = m1;
m = n1;
while(h - m < 0) {
m = ceil((float)m / 2.0);
cnt++;
}
while(w - n < 0){
n = ceil((float)n / 2.0);
cnt++;
}
int ans = min(cnt, v1);
cout << ans << endl;
}