All possible combination of N numbers to sum X
问题 I have to write a program that given n , target and max , returns all the number combinations of size n that sums to target , where no number can be greater than max Example: target = 3 max = 1 n = 4 Output: [0, 1, 1, 1] [1, 0, 1, 1] [1, 1, 0, 1] [1, 1, 1, 0] It is a very simple example, but there can be a very large set of possible combinations for a more complex case. I'm looking for any algorithmic clue, but a Java implementation would be perfect. 回答1: Here a java version: import java.util