A favorite function
Practice
3 (2 votes)
Integer factorization
Math
Implementation
Mathematics
Sieve
Basics of implementation
Number theory
Problem
83% Success 310 Attempts 30 Points 1.5s Time Limit 256MB Memory 1024 KB Max Code

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 calls\( f(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 \in [L, R],\ f(x) = y}|\) and let \(mx\) be maximum value of \(cnt\) over all \(y's\) and \(y\) which is the largest possible \(y\) which \(cnt(y) = mx\), you should print \(y\div mx\).

Constraints

\(1≤T≤10\)

\(1≤L≤R≤5*10^6\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
4 votes
Tags:
Number TheoryPrime FactorizationEasy-MediumMathematicsSieveFactorization
Points:30
5 votes
Tags:
MathematicsApprovedEasy-MediumFactorization
Points:30
Tags:
MathematicsEasy-MediumFactorization