# Partition a set into k subset with equal sum

A set is given. You have to make **K** subsets by which all of the subsets have equal sum.

Test case T
// T no. of line with the value of N and corresponding values and the value of K.
E.g.
2
29
71 69 9 16 41 50 97 24 19 46 47 52 22 56 80 89 65 29 42 51 94 1 35 65 25 15 88 57 44
2
15
29 28 51 85 59 21 25 23 70 97 82 31 85 93 73
3
Constraints:
1<=T<=100
1<=N,K<=100
1<=Set[] <=100
Output:
Print T lines either **Partition possible** or **Partition is not possible**.

**Example**

Input:
N=15
Set[]= { 29 28 51 85 59 21 25 23 70 97 82 31 85 93 }
K=3
Then the subsets are:
{85,21,23,70,85}
{28,59,31,93,73}
{29,51,25,97,82}
Output:
Partition possible

Let there is a set of

Npositive numbersX1, X2, X3, ..., Xn.To make

Kno. of subset with equal sum is a problem of combination and we solve it using backtracking. We will follow some possible path to solve this problem.Kequals to 1 then it always true and the value ofKis greater thanNthen it is impossible so it is false then.K.kthen we will go to the step 4 otherwise it is false.Sum/K) and make the mark which of the elements are taken consideration.Sum/K).For the input,

Firstly, we calculate the total

Sum = 779andK = 3. So,779is divisible by3.Then we will choose any of the value from starting and start our backtracking algorithm according to that and find the subsets with equal sum,

C++ implementation:

need an explanation for this answer? contact us directly to get an explanation for this answerOutput