Advertisement
tepyotin2

#1.3 Wall Painting

Dec 9th, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     ios_base::sync_with_stdio(0), cin.tie(0);
  7.     // freopen("wpainting.in", "r", stdin);
  8.     int n, m;
  9.     cin >> n >> m;
  10.     int ans = 0;
  11.     int val = 1;
  12.     int bn = 0, bm = 0;
  13.     if(n%2==1 && m%2==1){
  14.         // cout << "HI" << '\n';
  15.         ans+=val;
  16.         bn=n;
  17.         bm=m;
  18.         n=(n+1)/2;
  19.         m=(m+1)/2;
  20.         // cout << n << ", " << m << '\n';
  21.         val=val*4;
  22.         while(n%2==0 && m%2==0 && bn!=n && bm!=m){
  23.             // cout << "HI2" << '\n';
  24.             ans+=val;
  25.             bn=n;
  26.             bm=m;
  27.             n=(n+1)/2;
  28.             m=(m+1)/2;
  29.             // cout << n << ", " << m << '\n';
  30.             val=val*4;
  31.         }
  32.     }
  33.     cout << ans << '\n';
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement