fork download
  1. #include <cmath>
  2. #include <climits>
  3. #include <queue>
  4. #include <vector>
  5. #include <map>
  6. #include <cstdlib>
  7. #include <fstream>
  8. #include <iomanip>
  9. #include <iostream>
  10. #include <sstream> // istringstream buffer(myString);
  11. #include <stack>
  12. #include <algorithm>
  13. #include <cstring>
  14. #include <cassert>
  15. //functions in code for optimization
  16. #define max(a,b) (a<b?b:a)
  17. #define min(a,b) (a<b?a:b)
  18. #define abs(x) (x<0?(-x):x)
  19. #define C2I(c) (c-'0')
  20. #define gcd __gcd
  21. //data types used often, but you don't want to type them time by time
  22. #define ll long long
  23. #define ull unsigned long long
  24. #define ui unsigned int
  25. //For Map, pair
  26. #define pb push_back
  27. #define mp make_pair
  28. #define fi first
  29. #define se second
  30. // for debug
  31. #define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl;
  32.  
  33. using namespace std;
  34. int check_dig(ll x,int t);
  35. int main()
  36. {
  37. //Your Code Starts here :*
  38. ll mul=0;
  39. ll a,b,c=0;
  40. int counter=0;
  41. cin>>a>>b>>c;
  42. vector<ll> raa;
  43. for(int i=1; i<=81; i++)
  44. {
  45. mul=(b*pow(i,a))+c;
  46. if(check_dig(mul,i))
  47. {
  48. if(mul<1000000000 )
  49. {
  50. counter++;
  51. raa.push_back(mul);
  52. }
  53. }
  54. }
  55. cout<<counter<<endl;
  56. for(int i=0; i!=(int)raa.size(); i++)
  57. cout<<raa[i]<<" ";
  58. return 0;
  59. }
  60. int check_dig(ll x,int t)
  61. {
  62. int sum=0;
  63. while(x>0)
  64. {
  65. sum=sum+x%10;
  66. x=x/10;
  67. }
  68. if(sum==t)
  69. return 1;
  70. else
  71. return 0;
  72. }
  73.  
Success #stdin #stdout 0s 3480KB
stdin
3 2 8
stdout
3
10 2008 13726