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. int pointY = 0, pointX = 0;
  17. int a = 0, b = 0;
  18.  
  19. // X == LINIE X = COLOANA
  20. // x = 1 || y = 1
  21. while (copyN > 1 || copyM > 1) {
  22. //a = 1 + ySteps; // (1 + 1 = 2),
  23. //b = 1 + xSteps; // (1 + 1 = 2),
  24. //a += ySteps; // 1
  25. //b += xSteps; // 1
  26.  
  27.  
  28. if (copyN - xSteps >= 1 && xSteps > 0 ) {// ()
  29. copyN -= xSteps;//
  30. // pointX += b; //
  31. ++counterSteps; //
  32. }
  33.  
  34. if (copyM - ySteps >= 1 ) {//
  35. copyM -= ySteps; //
  36. // pointY += a; //
  37. ++counterSteps;//
  38. }
  39.  
  40. if (copyN - xSteps < 1 && copyN > 1) {
  41. --xSteps;//
  42. }
  43.  
  44. if (copyM - ySteps < 1 && copyM > 1) {
  45. --ySteps;//
  46. }
  47.  
  48. //--ySteps;//
  49. //--xSteps;
  50. }
  51. cout << counterSteps;
  52. return 0;
  53. }
Success #stdin #stdout 0.01s 5288KB
stdin
2 7 
1 2 
1 2 3 4 5 6 7 
1 2 3 4 5 6 7 
stdout
4