Problem Link : https://www.codechef.com/problems/NUMFACT
This is my code for above problem. My code is passing the test case but when I ran it it could only able pass subtask 1, not others. So, please help me out to figure out my mistake.
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
// your code goes here
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
ll arr[n];
ll maximum = INT_MIN;
for(ll i = 0; i<n; i++){
cin>>arr[i];
maximum = max(maximum, arr[i]);
}
ll dp[maximum + 1];
memset(dp, 0, sizeof(dp));
for(ll i = 0; i<n; i++){
while(arr[i] % 2 == 0){
arr[i] = arr[i]/2;
dp[2]++;
}
for(ll j = 3; j < sqrt(arr[i]); j++){
while(arr[i] % j == 0){
arr[i] = arr[i]/j;
dp[j]++;
}
}
if(arr[i] > 2) dp[arr[i]]++;
}
ll count = 1;
for(ll i = 0; i <= maximum; i++){
count = count * (dp[i] + 1);
}
cout<<count<<endl;
}
return 0;
}