A favorite function

3

2 votes
Integer Factorization, Math, Implementation, Mathematics, Sieve, Basics of Implementation, Number Theory
Problem

Bob loves to factor numbers. His favorite function was f(x) which equal the number of divisors of x.

For the birthday party, some friends came to Bob's house and each gift a pair of integers L and R. Seizing the opportunity, the birthday boy began to entertain the guests as follows:

For each number x in the range [L,R], he counted f(x). Then, he chose from these f(x)s the one that occurred to him the maximum number of times. And, at the top of his voice, he callsf(x) and how many times it occurred in this range.

If correct answers are (a, b) and (c, d) that is a=b and b!=d, then print a b if b > d or print c d in other cases.

While the friends are having fun, try repeating Bob's trick yourself.

Input format

  • The first line contains T denoting the number of tests.
  • The next T lines contain each set of two integers L and R.

Output format

For each test case, print two numbers denoting the value of f(x) and the number of such numbers.

Formally, let cnt(y)=|x[L,R], f(x)=y| and let mx be maximum value of cnt over all ys and y which is the largest possible y which cnt(y)=mx, you should print y÷mx.

Constraints

1T10

1LR5106

Time Limit: 1.5
Memory Limit: 256
Source Limit:
Explanation

For the first 11 numbers:

f(1) = 1

f(2) = 2

f(3) = 2

f(4) = 3

f(5) = 2

f(6) = 4

f(7) = 2

f(8) = 4

f(9) = 3

f(10) = 4

f(11) = 2

For f(x) from numbers 2...9, the most common ones are those with two divisors (2,3,5,7).

Editor Image

?