-
December 12th, 2012, 08:13 AM
#1
nested for loops
hi,
i am currently trying to teach my self c++. Workign fin so far, but now i have hit a break with this problem:
(translated by me, sorry)
1) you are given a large number x and a subset of smaller numbers a<b<c<d. Find the smallest amount of a,b,c,d possible to reach x.
So you are supposed to find a combination like "5*a + 3*b + 1*d" == x, where 5+3+1 is the smallest possible.
I thought a lot about this, no success. :/
I would have otped for bruteforce testing all possible combinations, but the book says no bruteforcing.
The example is taken from the "advanced" part of my book, chapter "loops and algorithms". A solution is supposed to be on an accompanying cd, but i lost that ages ago.
any hints for me?
p.s. coudlnt think of a proper title, sorry...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|