may be u can try to find a more general formula for the series..which just depends on 'n'...
On Sat, Mar 19, 2011 at 11:48 PM, cegprakash <[email protected]> wrote: > Here is my code for TRICOUNT problem > > //http://www.spoj.pl/problems/TRICOUNT/ > //[email protected] > > #include<iostream> > #include<conio.h> > using namespace std; > unsigned long long start,end,arr[1000001],arr2[1000001]; > //number of triangles facing upwards=arr > //number of triangles facing downwards=arr2 > > int main(){ > int j,t,i,n; > for(i=0;i<10000;i++){ > arr[i]=i+1+arr[i-1]; > } > for(i=0;i<10000;i++) > { > arr[i]+=arr[i-1]; > } > arr2[1]=1; > for(i=2;i<=10000;i++){ > arr2[i]=0; > for(end=i;;end=end-2){ > arr2[i]+=end*(end+1)/2; > if(end<=2) break; > } > } > cin>>t; > while(t--){ > cin>>n; > cout<<arr[n-1]+arr2[n-1]<<endl; > } > > > > return 0; > } > > > my algorithm is fast upto input value of 10^4. i donno why my > algorithm doesn't satisfy 10^6 > someone help > > -- > 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.
