Advertisement
Josif_tepe

Untitled

Apr 7th, 2025
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6.  
  7. int main() {
  8.     int a, b;
  9.     cin >> a >> b;
  10.    
  11.     if(a < b) {
  12.         swap(a, b);
  13.     }
  14.    
  15.     int res = 2e9;
  16.     for(int i = 0; i <= a; i++) {
  17.         if(((a - i) % 3 != 0) and ((b + i) % 3 != 0)) {
  18.             res = min(res, abs((b + i) - (a - i)));
  19.         }
  20.     }
  21.     cout << res << endl;
  22.    
  23.    
  24.     return 0;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement