lightoj1202

maksyuki 发表于 oj 分类,标签:
0

1202 - Bishops

Now you are given the position of the two bishops. You have to find the minimum chess moves to take one to another. With a chess move, a bishop can be moved to a long distance (along the diagonal lines) with just one move.There is an Infinite chessboard. Two bishops are there. (Bishop means the chess piece that moves diagonally).

Input

Input starts with an integer T (≤ 10000), denoting the number of test cases.

Each case contains four integers r1 c1 r2 c2 denoting the positions of the bishops. Each of the integers will be positive and not greater than 109. You can also assume that the positions will be distinct.

Output

For each case, print the case number and the minimum moves required to take one bishop to the other. Print 'impossible' if it's not possible.

Sample Input

Output for Sample Input

31 1 10 101 1 10 111 1 5 3 Case 1: 1Case 2: impossibleCase 3: 2

 

题目类型:简单数学

算法分析:如果两个点的坐标都不相等且之间的直线的斜率为1或者是-1,则输出1,反之继续判断。判断的思路是做两条过两点,斜率分别为1和-1的直线,判断两直线的交点是否在整数点上