Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5. int n, m;
  6.  
  7. __int128 mas[50][50] = {};
  8.  
  9. __int128 stupid_horse(int x, int y) {
  10.     if (x == n - 1 && y == 0) return 1;
  11.     __int128 a = 0, b = 0, c = 0, d = 0;
  12.     if (x + 2 < n && y + 1 < m && mas[x + 2][y + 1] == 0) {
  13.         mas[x + 2][y + 1] = stupid_horse(x + 2, y + 1);
  14.     }
  15.     if (x + 2 < n && y + 1 < m){
  16.         a = mas[x + 2][y + 1];
  17.     }
  18.     if (x + 2 < n && y - 1 >= 0 && mas[x + 2][y - 1] == 0) {
  19.         mas[x + 2][y - 1] = stupid_horse(x + 2, y - 1);
  20.     }
  21.     if (x + 2 < n && y - 1 >= 0){
  22.         b = mas[x + 2][y - 1];
  23.     }
  24.     if (x + 1 < n && y - 2 >= 0 && mas[x + 1][y - 2] == 0) {
  25.         mas[x + 1][y - 2] = stupid_horse(x + 1, y - 2);
  26.     }
  27.     if (x + 1 < n && y - 2 >= 0){
  28.         c = mas[x + 1][y - 2];
  29.     }
  30.     if (x - 1 >= 0 && y - 2 >= 0 && mas[x - 1][y - 2] == 0) {
  31.         mas[x - 1][y - 2] = stupid_horse(x - 1, y - 2);
  32.     }
  33.     if (x - 1 >= 0 && y - 2 >= 0){
  34.         d = mas[x - 1][y - 2];
  35.     }
  36.     return a + b + c + d;
  37. }
  38.  
  39. int main() {
  40.     cin >> n >> m;
  41.     __int128 jopa = 0;
  42.     jopa = stupid_horse(0, m - 1);
  43.     int number[128];
  44.     for (int i = 0; i < 128; ++i) {
  45.         number[i] = jopa % 10;
  46.         jopa /= 10;
  47.     }
  48.     bool is_one = false;
  49.     for (int j = 127; j >= 0; --j) {
  50.         if (number[j] != 0) is_one = true;
  51.         if (is_one) {
  52.             cout << number[j];
  53.         }
  54.     }
  55.     if (is_one == false) cout << 0;
  56.     return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement