Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Algorithm

Name: Anonymous 2010-10-21 11:53

There's a n-element array of integers- 1 or 2.
We have to find subsequence which sum equals x.
How to do that ? I have no fucking idea.
Inb4 bruteforce

Name: Anonymous 2010-10-22 6:30

>>46
Yes, that's crucial, otherwise the problem (2, -1) with target 1 is a counter-example. Or (1, 1, 10, 1, 1, -5) with target 9, to make the problem more obvious.

Also, the fact that the only possible numbers are 1 and 2 is absolutely crucial for the "find a subset" interpretation, otherwise it's NP-complete: http://en.wikipedia.org/wiki/Subset_sum_problem, even with positive integers only.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List