Advertisement
myloyo

тг квиз 7

Feb 26th, 2023
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. int f(int sx, int sy, int fx, int fy, int c, int c1) {
  8. if (sx == fx && sy == fy && c == 17 && c1 <= 1) {
  9. return 1;
  10. }
  11. else if (c > 17 || c1 > 1) {
  12. return 0;
  13. }
  14. else if (c1 != 1) {
  15. 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);
  16. }
  17. else
  18. return f(sx + 1, sy, fx, fy, c+1, c1) + f(sx, sy + 1, fx, fy, c+1, c1);
  19.  
  20. }
  21.  
  22. int main() {
  23. cout << f(0, 0, 6, 9, 0, 0);
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement