【发布时间】:2017-01-19 05:03:23
【问题描述】:
我想制作一个 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
【问题讨论】:
-
跟我的要求不一样。
标签: java