Author: Karan Malhotra
Tester Dushyant Singh , Deepansh Parmani
Editorialist: Karan Malhotra
The problem basically asks to print the minimum count of positive integers , such that the sum of each (integer raised to the power 2) results in the given number N
The answer is the number of set bits in N
Every Natural Number can be represented as a sum of distinct powers of 2.Each set bit represents a distinct power.For eg - 5 (101) = 2^0 + 2^2 , the 0th and 2nd bit are set from left and the distinct powers are 1(2^0) & 4(2^2).
Many languages have built in functions to count the number of set bits.Other solutions also exist which involve manipulation of bits.Check solution for the same.
AUTHOR’S AND TESTER’S SOLUTIONS:
Author’s solution can be found here.