How to check if a integer is sum of given integers?

Posted by p3trix on Stack Overflow See other posts from Stack Overflow or by p3trix
Published on 2010-05-26T12:28:43Z Indexed on 2010/05/26 12:31 UTC
Read the original article Hit count: 288

Filed under:
|
|
|

Lets say I have a integer result and an array of integers, lets say [a,b,c] (not a fixed length). I need to detect if result=a*i +b*j + c*k, with i,j,k>=0.

I prefer a solution in C/C# if it is possible.

PS The problem is from a reservation system, a trip can be sold if its durations is a combination of given durations.

Thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about algorithm