fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int minimumSteps(int n, int m, int x, int y) {
  5. int totalSteps = (n - 1) / y + (m - 1) / x;
  6. if ((n - 1) % y) {
  7. ++totalSteps;
  8. }
  9. if ((m - 1) % x) {
  10. ++totalSteps;
  11. }
  12. return totalSteps;
  13. }
  14.  
  15. int main() {
  16. int n, m, x, y;
  17. cin >> n >> m;
  18. cin >> x >> y;
  19. cout << minimumSteps(n, m, x, y);
  20. return 0;
  21. }
Success #stdin #stdout 0s 5288KB
stdin
5 5
2 3
stdout
4