algorithm - Maximum number divisible by another one created from sum of previous numbers -


there given numbers 1, 2, ...., b-1. every number of these can used a[1], a[2], ...., a[b-1] times.

from them biggest possible number (from data given) has concatenated, while sum of digits (partial numbers) has divisible b. "digits" of number can of base bigger 2.
biggest number of base b has created, concatenating numbers 1...b-1, a[1]...a[b-1] times each, while sum of used partial numbers/digits has divisible b.

for example:
there 5 times 1, 10 times 2, 4 times 3 , 2 times 4. stated above, have concatenate biggest number divisible b (here 5).
give:
44333322222222221111.
concatenating biggest lowest gives needed number, sum divisible 5.
1 times 1 is:
0
because 1 not divisible 2, no numbers should used then.

what algorithms or similar problems this? how can approached?

at first, can arrange numbers biggest lowest, concatenated number naturally biggest. then, have take least amount of these numbers, sum divisible b. when there can taken different combinations of these numbers in same amounts, 1 has biggest number smallest among others should choosen (or second biggest , on).
example:
if combinations of (3, 3, 2) , (4, 2, 2) can taken, first 1 should cut out number.

this looks change-making problem, finite amount of coins of different denominations , @ end, have have combination, not minimal amount of coins. in addition, dynamic approach, 2 different combinations of same length (like 332 , 442 above) can't rather chosen in middle of dynamic array, in next steps can give quite different values.


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -