I'm programming in java and I need to formulate an algorithm. The requirements of the algorithm are:
- We have 3 Integer variables
n,m,k; - We want to divide
nintokparts so that the sum of thek-parts are equal tonand each part is an integer between1andm. - We want all possible combinations with the allowed integers.
For example with input set:
n = 7; m = 3; k = 4
we have two different combinations that we can formulate:
7 = 2 + 2 + 2 + 1
and
7 = 3 + 2 + 1 + 1
thank you all.
The idea is a backtraking algorithm approach (with recursion), You can decrease parameters and get partials solutions and then check if you have a right solution.