read topcoder tutotial http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=primeNumbers hope will be useful
On Fri, Jun 3, 2011 at 5:33 PM, kartik <[email protected]> wrote: > what's worng in my code..........why the judge is giving > TLE.............plzz help me out > my code is > # include<stdio.h> > int main() > { > long long int phi[1000001]; > long long int n=1000000,k,i,j; > > phi[1]=1; > for ( i=2; i<=n; ++i) phi[i]=i; > for ( i=2; i<=n; ++i) > if (phi[i]==i) // prime > for ( j=i; j<=n; j+=i) > phi[j]=phi[j]/i*(i-1); > > int t; > scanf("%d",&t); > > while(t--) > { > scanf("%lld",&k); > printf("%lld",phi[k]); > } > return 0; > } > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
