Created
May 28, 2016 16:02
-
-
Save viliml/2eb8adfb4db2d8c7454e363d08712ef1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment