I think the output is wrong. It should be
1 3 4 9 n in no call them ai's a[1] to a[n]
4 5 10 7 12 13 m in no call them bi's b[1] to b[m]
I assume starting from 1 to make manipulation easier
n(n-1)/2= m
n(n-1)=2m
n2 -n -2m=0
using quadratic formula:-
n=1 + sqrt( 1+8m)/2
This will always be a
That is exactly what my solution is doing.
On Thu, Feb 24, 2011 at 5:09 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
There must be another good solution..please let me know .
Thanks
On Thu, Feb 24, 2011 at 5:09 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
I think..
I think..
As like no are a,b,c,d,e
so sum will be
a+b,a+c,a+d,a+e,b+c,b+d,b+e,c+d,c+e,d+e;
so maximuum value will be d+e which is last element of array given
take last three value
1.c+d
2.c+e
3.d+e
eq(1)-eq(2)=d-e;
solving it with 3rd eq will give d and e
and with these value we can get other
There must be another good solution..please let me know .
Thanks
On Thu, Feb 24, 2011 at 5:09 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
I think..
As like no are a,b,c,d,e
so sum will be
a+b,a+c,a+d,a+e,b+c,b+d,b+e,c+d,c+e,d+e;
so maximuum value will be d+e which is last
Last three values could be:
1.b+e
2.c+e
3.d+e
On Thu, Feb 24, 2011 at 5:09 PM, ashish agarwal
ashish.cooldude...@gmail.com wrote:
I think..
As like no are a,b,c,d,e
so sum will be
a+b,a+c,a+d,a+e,b+c,b+d,b+e,c+d,c+e,d+e;
so maximuum value will be d+e which is last element of array given
If pairwise sums of 'n' numbers are given in non-decreasing order
identify the individual numbers. If the sum is corrupted print -1
Example:
i/p:
4 5 7 10 12 13
o/p:
1 3 4 9
Thanks Regards
Shashank
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks
This s a topcoder problem :)
On Wed, Feb 23, 2011 at 7:16 PM, bittu shashank7andr...@gmail.com wrote:
If pairwise sums of 'n' numbers are given in non-decreasing order
identify the individual numbers. If the sum is corrupted print -1
Example:
i/p:
4 5 7 10 12 13
o/p:
1 3 4 9
Thanks
If pairwise sums of ānā numbers are given in non-decreasing order
identify the individual numbers. If the sum is corrupted print -1
Example:
i/p:
4
4 5 7 10 12 13
o/p:
1 3 4 9
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this