fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 20;
  5.  
  6. int main() {
  7. int n, m , x, y, mt[MAX_SIZE + 1][MAX_SIZE + 1];
  8. cin >> n >> m >> x >> y;
  9. for (int i = 1; i <= n; ++i) {
  10. for (int j = 1; j <= m; ++j) {
  11. cin >> mt[i][j];
  12. }
  13. }
  14. int counterSteps = 0, xSteps = x, ySteps = y;
  15. int copyN = n, copyM = m;
  16.  
  17. // X == LINIE X = COLOANA
  18. // x = 1 || y = 1
  19. while (copyN > 1 || copyM > 1) {
  20.  
  21. if (copyN - xSteps >= 1 && xSteps > 0 ) {// ()
  22. copyN -= xSteps;//
  23. // pointX += b; //
  24. ++counterSteps; //
  25. }
  26.  
  27. if (copyM - ySteps >= 1 ) {//
  28. copyM -= ySteps; //
  29. // pointY += a; //
  30. ++counterSteps;//
  31. }
  32.  
  33. if (copyN - xSteps < 1 && copyN > 1) {
  34. --xSteps;//
  35. }
  36.  
  37. if (copyM - ySteps < 1 && copyM > 1) {
  38. --ySteps;//
  39. }
  40.  
  41. //--ySteps;//
  42. //--xSteps;
  43. }
  44. cout << counterSteps;
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5308KB
stdin
2 10
1 8 
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
stdout
3