| #include <stdio.h> |
| #include <stdlib.h> |
| #include <string.h> |
| |
| int main() { |
| int Horse_y[8] = { 2, 1, -1, -2, -2, -1, 1, 2 }; |
| int Horse_x[8] = { 1, 2, 2, 1, -1, -2, -2, -1 }; |
| int x_destination, y_destination, x_horse, y_horse; |
| scanf("%d %d %d %d", &x_destination, &y_destination, &x_horse, &y_horse); |
| int board[x_destination + 1][y_destination + 1]; |
| memset(board, 0, sizeof(board)); |
| long long methods[x_destination + 1][y_destination + 1]; |
| memset(methods, 0, sizeof(methods)); |
| |
| board[x_horse][y_horse] = 1; |
| for (int i = 0; i < 8; i++) { |
| int x_jump = x_horse + Horse_x[i]; |
| int y_jump = y_horse + Horse_y[i]; |
| if (x_jump < 0 || x_jump > x_destination || y_jump < 0 || y_jump > y_destination) |
| continue; |
| board[x_jump][y_jump] = 1; |
| } |
| |
| methods[0][0] = 1; |
| for (int i = 0; i <= x_destination && board[i][0] == 0; i++) |
| methods[i][0] = 1; |
| for (int j = 0; j <= y_destination && board[0][j] == 0; j++) |
| methods[0][j] = 1; |
| for (int i = 1; i <= x_destination; i++) |
| for (int j = 1; j <= y_destination; j++) { |
| if (board[i][j] == 1) |
| continue; |
| methods[i][j] = methods[i - 1][j] + methods[i][j - 1]; |
| } |
| printf("%lld", methods[x_destination][y_destination]); |
| system("pause"); |
| return 0; |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本