What is the concept in this editorial

I found this editorial to be written in very unclear language, can anyone please explain this editorial??

link to editorial :- https://discuss.codechef.com/questions/58420/sanskar-editorial?sort=votes&page=2

link to the problem:- https://www.codechef.com/problems/SANSKAR

#include <stdio.h>
void main()
int a,b,temp;
scanf("%d %d",&a,&b);
printf("%d %d",a,b);


Given a set U of N integers the task is decide if it is possible to divide them into K non-empty groups such that the sum of elements in each of the K groups is equal.


  1. Denote the total sum S of all integers in U, and the required sum M=S/K of each of the K groups. If M is not an integer, then there’s no solution.
  2. DP on each possible subset X\subseteq U, dp[X]=1 iff X can be partitioned into k groups each sums to M, and a last (possibly empty) group sums to r \in [0,M-1], assume sum of integers in X is S_x=kM+r.
    3. dp[\emptyset]=1,
    3. Initially dp[X]=0; For each integer x\in X, let Y=X\setminus \{x\}, if x\le r(or x\le M if r=0) and dp[Y]=1, then dp[X]=1.
    4. dp[U] gives the final answer.
  3. Use a N-bit bitmask to represent and iterate subsets.