Beauty of the array

4.3

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

Given an array Arr of N positive integers.
Omega of a number X is defined as the set of prime numbers that divide X.
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 109+7).

Input format

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

Output format

  • Print the beauty of the given array.

Constraints

  • 1N106
  • 1Arr[i]105
Sample Input
7
6 18 2 4 1 8 1
Sample Output
12
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Example: Arr = [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

?