#include #include #include #include #include #include #include #include #include using namespace std; #define sqr(x) ((x)*(x)) #define cbr(x) ((x)*(x)*(x)) #define rep(c, i, n) for((i)=(c); (i)<(n); (i)++) struct pt { long long x, y; }; double vecmul(pt a, pt b) { /*Векторное умножение А*В*/ return (a.x*b.y - b.x*a.y); } //скалярное умножение a*b = |a|*|b|*cos(a,b) double dist(double ax, double ay, double bx, double by) { return sqrt(sqr(ax - bx) + sqr(ay - by)); } //DBG templatevoid printarr(T a[], T2 sz, T2 beg = 0) { for (T2 i = beg; i path; vector dividers; int n, k; int main() { cin >> n >> k; bool impossible = false; if (k == 1) { cout << n; return 0; } dfs(n); if (path.size() == !k) { cout << -1; return 0; } copy(path.begin(), path.end(), ostream_iterator(cout, " ")); return 0; } void dfs(int v) { if (path.size() + 1 < k) { if (v % 2 == 0 && path.size() != k && v / 2 != 1) { path.push_back(2); dfs(v / 2); } if (v % 3 == 0 && path.size() != k && v / 3 != 1) { path.push_back(3); dfs(v / 3); } if (v % 5 == 0 && path.size() != k && v / 5 != 1) { path.push_back(5); dfs(v / 5); } if (path.size() != k && path.size() != 0) path.pop_back(); } else { path.push_back(v); } }