fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. typedef long long ll;
  7.  
  8. int main()
  9. {
  10. ll n, m;
  11. cin >> n >> m;
  12.  
  13. ll maxN = 2 * n;
  14. ll maxM = 3 * m;
  15.  
  16. for (int i = 2; i <= min(maxN, maxM); i += 2)
  17. {
  18. if (i % 3 == 0)
  19. {
  20. if (maxN <= maxM) maxN += 2;
  21. else maxM += 3;
  22. }
  23. }
  24.  
  25. ll maxTower = max(maxN, maxM);
  26. cout << maxTower;
  27. }
Success #stdin #stdout 0s 3464KB
stdin
6 3
stdout
14