CF2008C.Longest Good Array

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Longest Good Array

Today, Sakurako was studying arrays. An array aa of length nn is considered good if and only if:

  • the array aa is increasing, meaning ai1<aia_{i - 1} \lt a_i for all 2in2 \le i \le n;
  • the differences between adjacent elements are increasing, meaning aiai1<ai+1aia_i - a_{i-1} \lt a_{i+1} - a_i for all 2i<n2 \le i \lt n.

Sakurako has come up with boundaries ll and rr and wants to construct a good array of maximum length, where lairl \le a_i \le r for all aia_i.

Help Sakurako find the maximum length of a good array for the given ll and rr.

Input

The first line contains a single integer tt (1t1041\le t\le 10^4)  — the number of test cases.

The only line of each test case contains two integers ll and rr (1lr1091\le l\le r\le 10^9).

Output

For each test case, output a single integer  — the length of the longest good array Sakurako can form given ll and rr.

Note

For l=1l=1 and r=5r=5, one possible array could be (1,2,5)(1,2,5). It can be proven that an array of length 44 does not exist for the given ll and rr.

For l=2l=2 and r=2r=2, the only possible array is (2)(2).

For l=10l=10 and r=20r=20, the only possible array is (10,11,13,16,20)(10,11,13,16,20).

Samples

5
1 2
1 5
2 2
10 20
1 1000000000
2
3
1
5
44721

在线编程 IDE

建议全屏模式获得最佳体验