Make it Equal

0

0 votes
Problem

You are given two integers a and b. You can perform a sequence of operations: during the first operation you choose one of these numbers and increase it by 1; during the second operation, you choose one of these numbers and increase it by 2, and so on. You choose the number of these operations yourself.

For example, if a=1 and b=3, you can perform the following sequence of three operations: 

  1. add 1 to a, then a=2 and b=3
  2. add 2 to b, then a=2 and b=5
  3. add 3 to a, then a=5 and b=5;

Calculate the minimum number of operations required to make a and b equal.

INPUT:

  • The only input will be unknown pair of a and b.
  • It is guaranteed that at max 100 pairs will be thrown in a test.

CONSTRAINTS:

  • 1 ≤ a, b ≤ 109

OUTPUT:

For each test case print one integer — the minimum numbers of operations required to make a and b equal.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?