SamsungOA #2
Reach The Point
估计中等可在线判题
考点(AI 标注)位运算
Start from (0,0) with initial strength K=1. One operation either increases x by K, increases y by K, or increases K by 1. Find the minimum number of operations to reach exactly (a,b); each test case is independent.
输入格式
The first line contains t, followed by t lines of a b. Full original bounds: 1≤t≤1000, 1≤a,b≤10^9.
输出格式
For each test case, output one line with the minimum number of operations, t lines in total.
样例 1
输入:
1
1 6
输出:
5
样例 2
输入:
1
1 1
输出:
2
样例 3
输入:
2
2 3
6 6
输出:
4
6
样例说明
The outputs of the three public examples are, in order: 5; 2; 4 / 6. They have been checked by independent enumeration or direct simulation.