Opening Faculty position in human genomics, UMB# Biology - 生物学
z*g
1 楼
You're given N signed integers a[1..N].
You need to find N correct signs s[1..N] (that is, numbers s[i] = +/-1),
such that
a[1]*s[1] + a[2]*s[2] + .. + a[N]*s[N] = 0.
Assume that the solution always exists.
Example: a = {5, 7, 3, -8, 1};
then the signs are: s = {1, 1, -1, 1, -1}
because: 5 + 7 - 3 - 8 - 1 = 0
(or symmetric solution: s = {-1, -1, 1, -1, 1})
brute force 2^n.
You need to find N correct signs s[1..N] (that is, numbers s[i] = +/-1),
such that
a[1]*s[1] + a[2]*s[2] + .. + a[N]*s[N] = 0.
Assume that the solution always exists.
Example: a = {5, 7, 3, -8, 1};
then the signs are: s = {1, 1, -1, 1, -1}
because: 5 + 7 - 3 - 8 - 1 = 0
(or symmetric solution: s = {-1, -1, 1, -1, 1})
brute force 2^n.