#include <iostream>
using namespace std;
long fact(int n)
{
if(n==1 || n==0)
return 1;
else
return n*fact(n-1);
}int main() {
int t,n;
cin>>t;
while(t--)
{
cin>>n;
int c=0,m,d=0,k=2,h=1;
m=n;
for(int i=2;i<=n;++i)
{
if(m%i==0)
{
if(k==i)
{
d++;
}
c++;
m/=i;
i=i-1;
}
else
{if(d>1)
h=h*fact(d);
d=0;
k++;
if(m==1)
{
break;
}
}
}
cout<<(fact(c))/h<<endl;
}
return 0;
}
This is my code. Its keeps saying time out 1s. How can i overcome this timeout issue.
Asked by: Nitesh_Prasad on April 7, 2019, 6:34 p.m. Last updated on April 7, 2019, 6:34 p.m.