Hi…I am a newbie at codechef…so i was practicing an easy program D1 given in the codechef site for calculating product of divisors…but the online judge keeps giving me the error “time limit exceeded”…can you help me in optimising the problem?
#include<iostream>
using namespace std;
int main()
{
unsigned long N, t=1;
int i;
cin>>N;
unsigned long *a=new unsigned long [N];
unsigned long *b=new unsigned long [N];
for(i=0; i<N; i++)
scanf ("%d", a+i);
for (int j=0; j<N; j++)
{
for(int k=1; k<a[j]; k++)
{
if (a[j]%k==0)
t=t*k;
if(t>9999)
t=t%10000;
}
b[j]=t;
t=1;
}
for(int y=0; y<N;y++)
printf("%.4d\n", b[y]);
delete []a; delete []b;
}