#include #include #include const long long N = 10000, M = 10000, W = 100000; inline long long cube(long long x) {return x*x*x;} int main(){ std::vector score(W, -1), last(W), todo(1); long long done = score[0] = 0, y; while (done < N){ std::vector ntodo; for (long long x : todo){ for (long long a = 1; (y = x + cube(a)) < W && a <= M; ++a) if (score[y] == -1){ last[y] = a; score[y] = score[x] + 1; ntodo.push_back(y); if (y >= 0 && y <= N) ++done; } for (long long a = 1; (y = llabs(x - cube(a))) < W && a <= M; ++a) if (score[y] == -1){ last[y] = x > cube(a) ? -a : a; score[y] = score[x] + 1; ntodo.push_back(y); if (y >= 0 && y <= N) ++done; } } todo = ntodo; } long long n; std::cin >> n; std::cout << score[n]; for (long long k = n; k != 0; ){ if (k > 0){ std::cout << ' ' << last[k]; k = k - cube(last[k]); } else{ std::cout << ' ' << -last[-k]; k = k + cube(last[-k]); } } std::cout << std::endl; return 0; }