Similar Chocolates

2.6

17 votes
Data Structures, Easy, Hash Maps, Hash Tables, Implementation
Problem

There are N chocolates denoted by array A where A[i] is the length of the i-th chocolate. Alice can melt each chocolate and then convert it into a chocolate whose length is any divisor of the number A[i]. So, a chocolate of length A[i] can be converted into X different types of chocolate where X is the count of divisors of the number A[i]. So you need to count the total unordered pair of chocolates such that their X value is same.

Input Format
The first line contains an integer N as input denoting the total number of elements in the array A.
The next line contains N space-separated integers that denote the elements of the array A.

Output Format
In the output, print the total number of ways as mentioned in the statement.

Constraints
1N105
1A[i]106

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

There is only one possible value i.e. to pick the chocolates 2 and 3 as both of them have 2 divisors hence their X value is same.

Editor Image

?