Knight Moves
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Description
编写一个程序,计算一个骑士从棋盘上的一个格子到另一个格子所需的最小步数。骑士一步可以移动到的位置由下图给出。

Input Format
第一行给出骑士的数量n 。
在接下来的3n 行中,每3 行描述了一个骑士。其中,
第一行一个整数L 表示棋盘的大小,整个棋盘大小为 L*L;
第二行和第三行分别包含一对整数(X,Y) ,表示骑士的起始点和终点。假设对于每一个骑士,起始点和终点均合理。
Output Format
对每一个骑士,输出一行一个整数表示需要移动的最小步数。如果起始点和终点相同,则输出0 。
3
8
0 0
7 0
100
0 0
30 50
10
1 1
1 1
5
28
0
Hint
4<=L<=300 保证1<=X,Y<=L-1
2025_07_07吉利学院暑假实训周-上机实践-7
- Status
- Done
- Rule
- XCPC
- Problem
- 12
- Start at
- 2025-7-7 14:00
- End at
- 2025-7-7 17:00
- Duration
- 3 hour(s)
- Host
- Partic.
- 27