Beauty of the array

4.3

3 votes
Math, Hashmap, Sieve, Number Theory, Integer Factorization, Algorithms, Datastructures, Basic Math
Problem

Given an array of positive integers.
Omega of a number is defined as the set of prime numbers that divide .
Example:
Omega of 10 is [2,5], Omega of 1 is [], and Omega of 18 is [2,3].
The beauty of the array is defined as the product of the frequency of different omegas occurring in the array. Return the beauty of the given array (in Modulo ).

Input format

  • The first line contains an integer , where denotes the size of the array .
  • The second line contains space-separated integers denoting array .

Output format

  • Print the beauty of the given array.

Constraints

Sample Input
7
6 18 2 4 1 8 1
Sample Output
12
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Example: = [6, 18, 2, 4, 1, 8, 1]
Omega of 6 : [2,3]
Omega of 18 : [2,3]
Omega of 2 : [2]
Omega of 4 : [2]
Omega of 1 : []
Omega of 8 : [2]
Frequency of [2,3] = 2, frequency of [] = 2, and frequency of [2] = 3.
So beauty is 2*2*3 = 12.

Editor Image

?