Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int n, m;
- __int128 mas[50][50] = {};
- __int128 stupid_horse(int x, int y) {
- if (x == n - 1 && y == 0) return 1;
- __int128 a = 0, b = 0, c = 0, d = 0;
- if (x + 2 < n && y + 1 < m && mas[x + 2][y + 1] == 0) {
- mas[x + 2][y + 1] = stupid_horse(x + 2, y + 1);
- }
- if (x + 2 < n && y + 1 < m){
- a = mas[x + 2][y + 1];
- }
- if (x + 2 < n && y - 1 >= 0 && mas[x + 2][y - 1] == 0) {
- mas[x + 2][y - 1] = stupid_horse(x + 2, y - 1);
- }
- if (x + 2 < n && y - 1 >= 0){
- b = mas[x + 2][y - 1];
- }
- if (x + 1 < n && y - 2 >= 0 && mas[x + 1][y - 2] == 0) {
- mas[x + 1][y - 2] = stupid_horse(x + 1, y - 2);
- }
- if (x + 1 < n && y - 2 >= 0){
- c = mas[x + 1][y - 2];
- }
- if (x - 1 >= 0 && y - 2 >= 0 && mas[x - 1][y - 2] == 0) {
- mas[x - 1][y - 2] = stupid_horse(x - 1, y - 2);
- }
- if (x - 1 >= 0 && y - 2 >= 0){
- d = mas[x - 1][y - 2];
- }
- return a + b + c + d;
- }
- int main() {
- cin >> n >> m;
- __int128 jopa = 0;
- jopa = stupid_horse(0, m - 1);
- int number[128];
- for (int i = 0; i < 128; ++i) {
- number[i] = jopa % 10;
- jopa /= 10;
- }
- bool is_one = false;
- for (int j = 127; j >= 0; --j) {
- if (number[j] != 0) is_one = true;
- if (is_one) {
- cout << number[j];
- }
- }
- if (is_one == false) cout << 0;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement