Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int f(int sx, int sy, int fx, int fy, int c, int c1) {
- if (sx == fx && sy == fy && c == 17 && c1 <= 1) {
- return 1;
- }
- else if (c > 17 || c1 > 1) {
- return 0;
- }
- else if (c1 != 1) {
- return f(sx + 1, sy, fx, fy, c + 1, c1) + f(sx, sy + 1, fx, fy, c + 1, c1) + f(sx-1, sy, fx, fy, c + 1, c1 + 1) + f(sx, sy-1, fx, fy, c + 1, c1 + 1);
- }
- else
- return f(sx + 1, sy, fx, fy, c+1, c1) + f(sx, sy + 1, fx, fy, c+1, c1);
- }
- int main() {
- cout << f(0, 0, 6, 9, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement