  Showing: Handle Score
@Ibrahim Nash 6420
@mb1973 5642
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4610
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Express as sum of power of natural numbers
Medium Accuracy: 58.61% Submissions: 415 Points: 4

Given two numbers n and x, find out the total number of ways n can be expressed as sum of xth power of unique natural numbers.

Example 1:

Input: n = 10, x = 2
Output: 1
Explanation: 10 = 12 + 32, Hence total 1 possibility.


Example 2:

Input: n = 100, x = 2
Output: 3
Explanation: 100 = 102
62 + 82 and 12 + 32 + 42 + 52 + 72
Hence total 3 possibilities.


You dont need to read input or print anything. Complete the function numOfWays() which takes n and x as input parameter and returns the total number of ways n can be expressed as sum of xth power of unique natural numbers.

Expected Time Complexity: O(n2logn)
Expected Auxiliary Space: O(n)

Constraints:
1 <= n <= 103
1 <= x <= 5

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:  