#include <iostream> #include <vector> #include <cstdint> #include <algorithm> #include <cmath> typedef std::vector<std::uint64_t> DType; DType CleaveDigit(std::uint64_t N){ std::uint64_t Radix = 10; DType v; while (N != 0){ v.push_back(N%Radix); N /= Radix; } return v; } std::uint64_t Calc(DType v){ std::uint64_t N = 0; for (auto&o : v) N += static_cast<std::uint64_t>(std::pow(o, v.size())); return N; } DType MakeHoge(std::uint64_t N){ DType R; DType T; std::uint64_t V; for (std::uint64_t i = 0; i < N; i++) { T = CleaveDigit(i); V = Calc(T); if (i == V) R.push_back(i); } return R; } bool Show(DType v){ std::cout << "RESULT:" << std::endl; for (auto& o : v){ std::cout << o<<','; } std::cout << std::endl; return true; } int main(){ DType v; static const std::uint64_t N = std::pow(10, 6); std::cout << "i seek to " << N << std::endl; v = MakeHoge(N); Show(v); return 0; }
Standard input is empty
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,