SP27225 KNMOVE - Knight Move
Description
Daniel is a chess player. At his free time, he usually plays chess with his family or his friends. But, sometimes they have their own activities, so Daniel can't play chess. He spends his time to learn about knight's move. He has 1,000 x 1,000 chessboard, numbered from 1 to 1,000. He wants to move his knight from (a,b) to (1,1) with minimum movement. Help Daniel to solve it.
Input Format
The input file consists of several lines.
The first line contains a single number t representing the number of question Daniel asked. \[ 1
Output Format
The output file should contains t lines.
The i-th line should contain one number – the minimum number of knight's movement.
Explanation/Hint
题目: 丹尼奥是一名棋手。他喜欢在空闲时间里和家人朋友们下棋。 但有时他们要去参加自己的活动,所以不能陪他下棋。 这时他会研究马的移动问题。
他有一个1000*1000的棋盘,编号1~1000。 他想用最少的步数从(a,b)走到(1,1)。 因为数学不好,所以他求助于你。请你帮助他解决这个问题。
输入: 输入包含多组数据。 第一行,输入一个t,表示有t个起点(a,b)。(1