# NUMFACT - Editorial

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);
}
}``````

I Even Tried Putting The Sieve Out , But Still i was only able to Solve only One Subtask !!! :’(

Hey whats wrong in my code here?

``````
program FACTORS;

uses Math;
var
t,n,num,product:longint;

function factors(fact:longint):longint;
var
no:longint = 0;
x:longint;
begin
for x := 1 to floor(sqrt(fact)) do
begin
if fact mod x = 0 then
begin
if x*x = fact then inc(no,1)
else inc(no,2);
end;
end;
factors := no;
end;
begin
while t <> 0 do
begin
product := 1;
while n <> 0 do
begin
product := product * num;
dec(n);
end;
writeln(factors(product));
dec(t);
end;
end.

``````

I am getting runtime error NZEC.

I have been trying to debug my code for so long still not able to figure out why it is giving a WA for the basic cases. Please if anyone could tell me where am I going wrong?
This is the link to my solution.
https://www.codechef.com/submit/complete/8669014

nice explanation.
I used sieve of eratosthenes to get all prime factors of number

Any special reason for using char type of array for storing primes by setter ?

https://www.codechef.com/viewsolution/14084014
WHY IS THIS SOLUTION GETTING A WA ON LAST CASE PLZ HELP!!

//