fork download
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. long int solve(int n, int m){
  9. // Complete this function
  10. // The Square is m x n
  11. long int step = 0;
  12. while (m>1){
  13. step++;
  14. m--;
  15. }
  16. while (n>1){
  17. step++;
  18. n--;
  19. }
  20. return step;
  21. }
  22.  
  23. int main() {
  24. long int n;
  25. long int m;
  26. cin >> n >> m;
  27. long int result = solve(n, m);
  28. cout << result << endl;
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 15224KB
stdin
3 2
stdout
3