Factors
Practice
2.6 (10 votes)
Sorting
Algorithms
Basics of greedy algorithms
Greedy algorithms
Problem
93% Success 1585 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Ben had two numbers $$M$$ and $$N$$. He factorized both the numbers, that is, expressed $$M$$ and $$N$$ as a product of prime numbers.
                  M = (P1A1)*(P2A2 )*(P3A3)*… *(PNAN)
                  N = (Q1B1)*(Q2B2 )*(Q3B3)*… *(QNBN)

  • Here, * represents multiplication.
  • P1, P...PN  are distinct prime numbers. 
  • Q1, Q...QN are distinct prime numbers.

Unfortunately, Ben has lost both the numbers $$M$$ and $$N$$ but still he has arrays $$A$$ and $$B$$. He wants to reterive the numbers $$M$$ and $$N$$ but he will not be able to. Your task is to determine the minimum and the maximum number of factors their product (that is, $$M*N$$) could have. Your task is to tell Ben the minimum and the maximum number of factors that the product of $$M$$ and $$N$$ could have.
Since the answer can be large, print modulo $$1000000007$$.

Input format

  • The first line contains an integer $$T$$ denoting the number of test cases. For each test case:
    • The first line contains an integer $$N$$ denoting the number of elements in arrays $$A$$ and $$B$$.
    • The second line contains $$N$$ space-separated integers of array $$A$$.
    • The third line contains $$N$$ space-separated integers of array $$B$$.

Output format

For each test case, print a single line line containing two integers denoting the minimum and maximum number of factors which a product of $$M$$ and $$N$$ could have.

Constraints

\(1 \leq T \leq 20000\)

\(1 \leq N \leq 200000\)

\(1 \leq A_i ,B_i \leq 10^6\)

The sum of $$N$$ over all test cases does not exceed 200000.

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
70 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms
Points:30
57 votes
Tags:
Basic ProgrammingBit ManipulationBit manipulationMathSorting
Points:30
17 votes
Tags:
AlgorithmsBasics of Greedy AlgorithmsC++Greedy Algorithms