Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- vector<int> sols(1, 1), curr;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n, i, j, d = 2, cnt;
- ostringstream sout;
- cin>>n;
- sout<<1;
- while (n != 1)
- {
- for (; n % d && d <= sqrt(n); ++d);
- if (d > sqrt(n))
- d = n;
- for (cnt = 0; n % d == 0; n /= d, ++cnt);
- curr = sols;
- sols.resize(sols.size() * (cnt + 1));
- for (i = 1; i <= cnt; ++i)
- {
- reverse(curr.begin(), curr.end());
- for (j = 0; j < curr.size(); ++j)
- {
- int& x = curr[j];
- x *= d;
- sout<<' '<<x;
- sols[i * curr.size() + j] = x;
- }
- }
- }
- cout<<sols.size()<<'\n'<<sout.str()<<'\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement