fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int sum(long long int n)
  4. {
  5. int sum,remainder;
  6. while(n != 0)
  7. {
  8. remainder = n % 10;
  9. sum = sum + remainder;
  10. n = n / 10;
  11. }
  12. return sum;
  13. }
  14. long long int p(int base,int exp)
  15. {
  16. long long int ans =1;
  17. for(int i=0; i<exp; i++)
  18. ans=ans*base;
  19. return ans;
  20. }
  21. int main()
  22. {
  23. int a,b,c,s,n=0;
  24. vector<long int> v;
  25. long int x;
  26. cin>>a>>b>>c;
  27. for(int i=1; i<=81; i++)
  28. {
  29. x=b*(p(i,a))+c;
  30. s=sum(x);
  31. if(s==i)
  32. {
  33. n++;
  34. v.push_back(x);
  35. }
  36.  
  37. }
  38.  
  39. cout<<n<<endl;
  40. vector<long int> :: iterator it;
  41. for(it=v.begin(); it!=v.end(); it++)
  42. {
  43. cout<<*it<<" ";
  44. }
  45.  
  46. }
Success #stdin #stdout 0s 3436KB
stdin
5 9998 9998
stdout
1
1933785806