Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
A=(a1, a2,.. aN}- set of n numbers elements- (positive integers) must be divided into K subsets in order to sums of all elements in each subset were equal to m=(a1+a2+..+an)/K.
Algorithm must count ALL such cases for A. If it’s impossible to divided set A program generates „IMPOSSIBLE”

for example:
A={a1,a2,a3,a4}={5,4,6,5}
K=2
m=(5+4+6+5)/2=10
Divided set: {(5,5),(4,6)}, 5+5=4+6

Input:
5 4 6 5
2
Output:
1


Thanks for HELP
Bkac
Posted
Updated 19-Oct-14 10:45am
v2
Comments
PIEBALDconsult 19-Oct-14 16:44pm    
Sounds like yet another example of the
http://en.wikipedia.org/wiki/Knapsack_problem
or
http://en.wikipedia.org/wiki/Bin_packing_problem

1 solution

We don't do your homework - it is set for a reason.

Try it yourself, you may find it is easier than you think!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900