|
-
Aug 21st, 2002, 08:39 PM
#8
Fanatic Member
Originally posted by bugzpodder
here is how u do it in psedocode:
in order to break m down:
declare boolean array arr[] and initialize each element to false
Code:
arr[0]<-true;
while (there is still change)
change=get change;
loop from 0 to n {i}
if arr[i]=true
set arr[i+change] <- true
now if arr[m] is true then you got your change. if not, check arr[m-1], arr[m+1], arr[m-2], arr[m+2] until you get something.
lol Destined this is the way to do it! guarentees 0.05 second run time (unless you want to make something crazy like 100000000000000 dollars). as long as your memory can hold that much boolean variables my method will work. i have already give you the code, Chris, the only thing i can do now is to answer any questions if you have any.
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
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
|