nice approach Ashish....thkz On Fri, Jul 9, 2010 at 11:14 AM, Ashish Goel <ashg...@gmail.com> wrote:
> a minor correction > >> nC2 possibilities >> >> so n can be found using nC2=say6 then n=4 >> >> >> a+b=p0 >> a+c=p1 >> a+d=p2 >> b+c=p3 >> b+d=p4 >> c+d=p5 >> >> 3a+b+c+d=po+p1+p2 >> b+c+d=(p3+p4+p5)/2 >> >> so a= (2(p0+p1+p2)-p3-p4-p5)/6 >> >> >> >> take case of 5 numbers {1,2,3,4,5} >> P={3,4,5,6,5,6,7,7,8,9} >> 5C2=10 so n=5 >> >> //b+c+b+d+b+e+c+d+c+e+d+e=3b+3c+3d+3e >> for (int i=0;i<n-1;i++) >> {sumX+=p[i];} >> >> for (int j=i+1;j<nC2;j++) >> sumY+=p[j]; >> sumY=sumY/(n-2); >> a[0]=(sumX-sumY)/(n-1); >> >> using this rest of the numbers can be found >> >> >> >> Best Regards >> Ashish Goel >> "Think positive and find fuel in failure" >> +919985813081 >> +919966006652 >> >> >> >> On Fri, Jul 9, 2010 at 9:21 PM, amit <amitjaspal...@gmail.com> wrote: >> >>> Given a list of numbers, A = {a0, a1, ..., an-1}, its pairwise sums P >>> are defined to be all numbers of the form ai + aj for 0 <= i < j < n. >>> For example, if A = {1,2,3,4}, then >>> P = {1+2, 1+3, 1+4, 2+3, 2+4, 3+4} = {3, 4, 5, 5, 6, 7}. >>> Now give you P, design an algorithm to find all possible A. >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algoge...@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@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 algoge...@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.