J

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
747 B
23
Indexable
Never
#include <bits/stdc++.h>

#define ll long long

using namespace std;

ll power(ll a, ll n) {
    if (n == 0) {
        return 1;
    } else {
        return power(a, n - 1) * a;
    }
}

ll digitSum(ll x) {
    ll res = 0;
    while (x > 0) {
        res += x % 10;
        x /= 10;
    }
    return res;
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    vector<ll> ans;
    
    for (int s = 1; s <= 81; ++s) {
        ll x = b * power(s, a) + c;
        if (s == digitSum(x) && 0 < x && x < 1e9) {
            ans.push_back(x);
        }
    }
    
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << ' ';
    }
    
    return 0; 
}