Recursion. Explain the code. Please : Find the number of ways that a given integer x can be expressed as the sum of the nth power of unique, natural numbers.
ex: If x=10, n=2
The only possible case is : 3^2 +1^2
Here is the solution i read some somewhere - 

    int solve(int x, const vector<int> &powers, int index) {
        if(index == 0) {
            return (x == 1) ? 1 : 0;
        }
        // else
        if(x == powers[index])
            return 1 + solve(x, powers, index - 1);
        // else
        int res = 0;
        res += solve(x - powers[index], powers, index - 1);
        res += solve(x, powers, index - 1);
        return res;
    }
    
    
    int main() {
        int x, n;
        cin >> x >> n;
        
        int pow = 1;
        vector<int> powers;
        for(int a = 2; pow <= x; a++) {
            powers.push_back(pow);
            pow = power(a, n);
        }
        
        cout << solve(x, powers, powers.size() - 1) << endl;        
        return 0;
    }
Here I'm not able to actually visualise it. How to think recursively?
Help please. Please explain the solve function ?