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
n
intok
parts so that the sum of thek
-parts are equal ton
and each part is an integer between1
andm
. - 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.