Welcome To SDIBT ACM-ICPC Online Judge

VIRTUAL JUDGE Recent Contest F.A.Qs Discuss Home ProblemSet Status Ranklist 4 Contest LoginRegister Exam
Problem 1061. -- Steps

Steps

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 4  Solved: 3
[Submit][Status][Discuss]

Description

Consider the process of stepping from integer x to integer y along integer points of the straight line. The length of each step must be non-negative and can be one bigger than, equal to, or one smaller than the length of the previous step. What is the minimum number of steps in order to get from x to y? The length of both the first and the last step must be 1.

Input

The input begins with a line containing n, the number of test cases. Each test case that follows consists of a line with two integers: 0<=x<=y <231.

Output

For each test case, print a line giving the minimum number of steps to get from x to y

Sample Input

3
45 48
45 49
45 50

Sample Output

3
3
4

HINT

Source

Waterloo local 2000.01.29

[Submit][Status][Discuss]

HOME Back

한국어 中文 English
All Copyright Reserved 2008-2010 SDIBT TEAM
GPL2.0 2003-2010 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin