montes332

C++ Mails

Oct 9th, 2025
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. static inline long long folds(unsigned long long x, unsigned long long lim){
  8.    
  9.     long long cnt = 0;
  10.     while (x > lim){
  11.         x = (x+1)/2;
  12.         ++cnt;
  13.     }
  14.     return cnt;
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20.     unsigned long long n,m,h,w;
  21.     if (!(cin>>n >>m >>h >> w)) return 0;
  22.    
  23.     unsigned long long f1 = folds(n,h) + folds(m,w);
  24.     unsigned long long f2 = folds(n,w) + folds(m,h);
  25.    
  26.     cout << min(f1,f2) << "\n";
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment