Four Distinct Factors

3.6

5 votes
Basic Math, , C++, Math
Problem

Bunty has a favorite number 4. He calls a number his favorite if it has exactly 4 distinct factors greater than 0. So Bunty wonders how many favorite numbers are there in the range [l,r]. Can you help him find that?

Input format

  • The first line contains an integer T denoting the number of test cases.
  • The only line of each test case contains two space-separated integers - l and r.

Output format

For each test case, print an integer - the number of favorite numbers in the given range.

Constraints

1T105
1lr106

 

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation
  • In the first test case, the 3 favorite numbers are 6, 8 and 10.
  • In the second test case, the 10 favorite numbers are 10, 14, 15, 21, 22, 26, 27, 33, 34 and 35.

 

Editor Image

?