Where Am i Going Wrong , Its Always SIGSEV and TLE on my Submission :’( , Plz help me Fast i Need to Brace up For IOI
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void solve(long long int *primes,long long int *n )
{
long long int *z = (long long int *)calloc(1001,sizeof
(long long int));
while(*n>1)
{
for(long long int i=0;i<168;i++)
{
if(*n%primes[i]==0){z[i]++;*n= *n/primes[i];i--;}
}
}
long long int prod=1;
for(long long int k=0;k<168;k++)if(z[k]!=0)prod*=(z[k]+1);
printf("%lld \n",prod);
//for(long int i=0;i<n&&primes[i]!=0;i++)printf("%ld \n",primes[i]);
}
int main()
{
long long int *primes;
primes = (long long int *)calloc(1001,sizeof(long long int));
primes[0]=2;
primes[1]=3;
long long int index=2;
for(long long int z=5;z<=1001;z+=2)
{
long long int fact=0;
for(long long int i=0;i<1001&&primes[i]!=0;i++)
{
if(z%primes[i]==0){fact++;break;};
}
if (fact==0)
{
primes[index]=z;
index++;
}
}
long long int t;
scanf("%lld",&t);
while(t--){
long long int n,prod=1,temp;
scanf("%lld",&n);
for(long long int i=0;i<n;i++){scanf("%lld",&temp);prod*=temp;}
solve(primes,&prod);
}
}