algorithm - How to do something in every possible order -
i've got next question. suppose have array y of n elements, positive ints. , have got value x (positive int). want sum values of array array r elements. , each element of r applies: r<=x.
i want less elements in r possible. have see order of elements n fits best in value of x, x - value of element of r little possible. illustration given below. calculate thought easiest approach check every possibillity, since it's given n @ maximum around 70. best way approach this?
example:
x = 100 y: 20, 50, 90, 40, 15, 30, 10 (so n = 7) r: 90+10 = 100 50+30+20 = 100 40+15 = 55
so there @ to the lowest degree 3 rows in efficient way.
algorithm row formula
No comments:
Post a Comment