Advertisement
Guest User

Untitled

a guest
May 28th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. vector<int> sols(1, 1), curr;
  6.  
  7. int main()
  8. {
  9. ios_base::sync_with_stdio(false);
  10. cin.tie(NULL);
  11.  
  12. int n, i, j, d = 2, cnt;
  13. ostringstream sout;
  14.  
  15. cin>>n;
  16.  
  17. sout<<1;
  18.  
  19. while (n != 1)
  20. {
  21. for (; n % d && d <= sqrt(n); ++d);
  22. if (d > sqrt(n))
  23. d = n;
  24. for (cnt = 0; n % d == 0; n /= d, ++cnt);
  25.  
  26. curr = sols;
  27.  
  28. sols.resize(sols.size() * (cnt + 1));
  29.  
  30. for (i = 1; i <= cnt; ++i)
  31. {
  32. reverse(curr.begin(), curr.end());
  33. for (j = 0; j < curr.size(); ++j)
  34. {
  35. int& x = curr[j];
  36. x *= d;
  37. sout<<' '<<x;
  38. sols[i * curr.size() + j] = x;
  39. }
  40. }
  41. }
  42.  
  43. cout<<sols.size()<<'\n'<<sout.str()<<'\n';
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement