FifthThread's blog

By FifthThread, history, 2 years ago, In English

Q1. Find the number of ordered positive pairs A,B such that the equation x^2-2Ax+B=0 as integral roots and B lies between L and R both inclusive.

Input Format: The first line conains a single integer T denoting the number of test cases The first line of each test case contains two integers l, r

Output: print number of ordered pairs for each test case

Constraints T<10

l,r < 10^12

Sample Input:

2

1 5

2 10

Output:

4

7

Explanation

For the first test case, the valid pairs are (1,1) (2,3) (2,4) (3,5)

My Approach:

a^2-b should be a perfect square, and a^2-b>=0. Now how to go further?

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?