Make it Equal
Practice
0 (0 votes)
Problem
22% Success 66 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code
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:
- add 1 to a, then a=2 and b=3;
- add 2 to b, then a=2 and b=5;
- 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.
Submissions
Please login to view your submissions
Similar Problems
Points:20
25 votes
Tags:
Binary SearchMath BasicAlgorithmsBasic MathMath
Points:20
1 votes
Tags:
Easy
Points:20
17 votes
Tags:
EasyBasic MathMathematicsMathematics
Editorial