Given two numbers X and N, find out the total number of ways X can be expressed as sum of Nth power of unique natural numbers.
Input : X = 10, N = 2 Output : 1 Explanation: 10 = 12 + 32, Hence total 1 possibility Input : X = 100, N = 2 Output : 3 Explanation: 100 = 102 OR 62 + 82 OR 12 + 32 + 42 + 52 + 72 Hence total 3 possibilities
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains a single line containing two space seperated integers denoting the values of X and N respectively.
For each test case output a new line containing a single integer denoting the total number of ways X can be expressed as sum of Nth power of unique natural numbers.
1 <= T <= 100
1 <= X <= 103
1 <= N <= 5
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.