fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstdint>
  4. #include <algorithm>
  5. #include <cmath>
  6. typedef std::vector<std::uint64_t> DType;
  7.  
  8. DType CleaveDigit(std::uint64_t N){
  9. std::uint64_t Radix = 10;
  10. DType v;
  11. while (N != 0){
  12. v.push_back(N%Radix);
  13. N /= Radix;
  14. }
  15.  
  16. return v;
  17. }
  18.  
  19. std::uint64_t Calc(DType v){
  20. std::uint64_t N = 0;
  21.  
  22. for (auto&o : v) N += static_cast<std::uint64_t>(std::pow(o, v.size()));
  23.  
  24. return N;
  25. }
  26.  
  27. DType MakeHoge(std::uint64_t N){
  28. DType R;
  29. DType T;
  30. std::uint64_t V;
  31.  
  32. for (std::uint64_t i = 0; i < N; i++)
  33. {
  34. T = CleaveDigit(i);
  35. V = Calc(T);
  36. if (i == V) R.push_back(i);
  37. }
  38.  
  39. return R;
  40. }
  41.  
  42. bool Show(DType v){
  43. std::cout << "RESULT:" << std::endl;
  44. for (auto& o : v){
  45. std::cout << o<<',';
  46. }
  47. std::cout << std::endl;
  48.  
  49. return true;
  50. }
  51.  
  52. int main(){
  53. DType v;
  54. static const std::uint64_t N = std::pow(10, 6);
  55. std::cout << "i seek to " << N << std::endl;
  56. v = MakeHoge(N);
  57. Show(v);
  58.  
  59. return 0;
  60. }
Success #stdin #stdout 1.18s 3476KB
stdin
Standard input is empty
stdout
i seek to 1000000
RESULT:
0,1,2,3,4,5,6,7,8,9,153,370,371,407,1634,8208,9474,54748,92727,93084,548834,