## Welcome To SDIBT ACM-ICPC Online Judge

Problem 1061. -- Steps## Steps

Time Limit: 1 Sec Memory Limit: 64 MB

Submit: 6 Solved: 5

[Submit][Status][Forum]## 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 <2^{31}.

## 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][Forum]

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