A quadratic equation

2.7

36 votes
Basic Number Theory-2, Algorithms, Math, Number Theory
Problem

Find the number of ordered positive pairs (B,C) such that the equation x22Bx+C=0 has integral roots and C lies between L and R both inclusive.

Input format

  • The first line contains a single integer T denoting the number of test cases.
  • The first line of each test case contains two space-separated integers L and R denoting the range of C.

Output format

For each test case, print a single integer denoting the number of ordered positive pairs possible. The output for each test case must be printed in a separate line.

Constraints

1T10

1L,R1012

Sample Input
2
1 5
2 10
Sample Output
4
7
Time Limit: 4
Memory Limit: 256
Source Limit:
Explanation

The valid pairs corresponding to the first test case is: (1, 1), (2, 3), (2, 4), (3, 5).
The valid pairs corresponding to the second test case is: (2, 3), (2, 4), (3, 5), (4, 7), (3, 8), (3, 9), (5, 9).

Editor Image

?