0
我想讓java程序從給定整數的特定數據(數組列表)中統計出所有可能的唯一方式。如何從給定整數的特定數據中找到所有唯一可能的分區方式
Example :
input: 3 6
1 2 3
output: 7
explanation: the first line contains two separated integers of value x,y.
the second line contains x separated integers
For y = 6 and x = {1, 2, 3} there are exactly seven ways:
1. {1, 1, 1, 1, 1, 1} <— sum up to 6
2. {1, 1, 1, 1, 2} <- sum up to 6
3. {1, 1, 1, 3} <- sum up to 4
4. {2, 2, 2} <— sum up to 6
5. {2, 2, 1, 1} <— sum up to 6
6. {1, 2, 3} <— sum up to 6
7. {3, 3} <- sum up to 6
可能的重複[對於給定的整數a,找到總和爲a的正整數的所有唯一組合](http://stackoverflow.com/questions/24046561/for-a-given-integer-a-find -all-unique-combinations-of-positive-integers-that-su) –
與我的要求不一樣。 –