THE POWER SUM
Approach :
1.
Kevin has cleverly solved this problem without sweating..... (NO surprise).
int count(int x,int n,int s,int v){
if(s == x) return 1;
else{
v++;
int res = 0;
while(s+pow(v,n) <= x){
res += count(x,n,s+pow(v,n),v);
v++;} //while loop
return res;


No comments:
Post a Comment