don't see the online compiler.. it doesn't allow such a large array.. try on LINUX.. this is the one I got a/c on SPOJ ..!! http://ideone.com/NdBYJ
On Sat, May 28, 2011 at 5:26 PM, Logic King <crazy.logic.k...@gmail.com>wrote: > @sukhmeet....your code is having runtime error !! > > > On Sat, May 28, 2011 at 4:48 AM, sukhmeet singh <sukhmeet2...@gmail.com>wrote: > >> follow what Akash said..!! >> in case you still need help just go through http://ideone.com/al0U0 in >> devcpp..!! >> >> On Sat, May 28, 2011 at 2:34 PM, Aakash Johari <aakashj....@gmail.com>wrote: >> >>> Precompute the values. and then do queries. >>> >>> >>> On Sat, May 28, 2011 at 1:46 AM, Akshata Sharma < >>> akshatasharm...@gmail.com> wrote: >>> >>>> My code gives TLE. What further optimization is required in my code?? >>>> https://www.spoj.pl/problems/FACVSPOW/ >>>> >>>> >>>> >>>> >>>> >>>> /*FACVSPOW*/ >>>> #include<stdio.h> >>>> >>>> >>>> >>>> >>>> #include<cmath> >>>> >>>> >>>> >>>> >>>> >>>> using namespace std; >>>> >>>> >>>> >>>> >>>> >>>> int calc(long n, long a) >>>> >>>> >>>> >>>> >>>> { >>>> if(((n*log(n)-n)+0.5*log(2*M_PI*n)-n*log(a))>=0) >>>> >>>> >>>> >>>> >>>> >>>> return 1; >>>> else return -1; >>>> >>>> >>>> >>>> >>>> } >>>> int main() >>>> >>>> >>>> >>>> >>>> { >>>> long t; >>>> scanf("%ld",&t); >>>> >>>> >>>> >>>> >>>> long a; >>>> while(t--) >>>> >>>> >>>> >>>> >>>> { >>>> scanf("%ld",&a); >>>> >>>> >>>> >>>> >>>> >>>> long lo=2*a; >>>> >>>> >>>> >>>> >>>> >>>> long hi=(long)(2.718281828*a) + 1; >>>> >>>> >>>> >>>> >>>> >>>> long mid; >>>> while(lo<hi) >>>> >>>> >>>> >>>> >>>> >>>> { >>>> mid=(lo+hi)/2; >>>> >>>> >>>> >>>> >>>> >>>> if(calc(mid,a)<0) >>>> >>>> >>>> >>>> >>>> >>>> lo=mid+1 >>>> else if(calc(mid,a)>0) >>>> >>>> >>>> >>>> >>>> >>>> hi=mid; >>>> >>>> if(calc(mid,a)>0 && calc(mid-1,a)<0) >>>> >>>> >>>> >>>> >>>> >>>> break; >>>> } >>>> printf("%ld\n",mid); >>>> >>>> >>>> >>>> >>>> } >>>> 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 algogeeks@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> algogeeks+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> -Aakash Johari >>> (IIIT Allahabad) >>> >>> >>> >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.