Need help with problem: NUMFACT

Problem name: NUMFACT
Problem link: NUMFACT Problem - CodeChef

My logic: Multiply all the given n number to form the original number, and just count the number of distinct divisors of the original number.

My code results in WA, can anybody correct me. Thanks in advance.

Code:

#include <bits/stdc++.h>
using namespace std;
#define fastio()
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
#define lli long long int
#define ll long long

int cnt_factors(int n)
{
int ans=0;

for(int i=1;i*i<=n;i++)
{
    if((n%i)==0)
    {
        ans++;
        if(i!=(n/i)) ans++;
    }
}

return ans;

}

void solve()
{
int n; cin>>n;

int prod=1;
for(int i=0;i<n;i++) 
{
    int x; cin>>x;
    prod*=x;
}

cout<<cnt_factors(prod)<<'\n';

return;

}

int main()
{
fastio();
int t=1;
cin>>t;
while(t–) solve();

return 0;

}

The constraints for each test case are: 1 ≤ N ≤ 10 and 2 ≤ A_{i} ≤ 10^6. This means that their product p is in the range 2^{10} ≤ p ≤ 10^{60}. A 32-bit integer variable cannot be used to store a value as large as 10^{60}. Try to use another approach to find the answer without computing p. Hint: think about how to find the answer from prime-number factorization of each number A_{i}.

The following is my accepted c++14 solution.

https://www.codechef.com/viewsolution/60437680