fork download
  1. #include <bits/stdc++.h>
  2. #define fast1 ios_base::sync_with_stdio(false)
  3. #define fast2 cin.tie(NULL)
  4. #define ll long long
  5. #define FOR(i,a,n) for(int i=a;i<n;i++)
  6. #define SIZE 10000001
  7. using namespace std;
  8. int a[SIZE]={0};
  9. void smallestprimefactor()
  10. {
  11. for(int i=2;i<=SIZE;i++)
  12. {
  13. if(a[i]==0)
  14. {
  15. a[i]=i;
  16. int j=2;
  17. while(i*j<=SIZE)
  18. {
  19. a[i*j]=i;
  20. j++;
  21. }
  22. }
  23. }
  24. }
  25. vector<int> primefactor(int n)
  26. {
  27. vector<int> res;
  28.  
  29. while(n>1)
  30. {
  31. res.push_back(a[n]);
  32. n=n/a[n];
  33. }
  34. return res;
  35. }
  36. int main()
  37. {
  38. fast1;fast2;
  39. int x;
  40. while(scanf("%d",&x)==1)
  41. {
  42. if(x==1)
  43. cout<<"1";
  44. else
  45. {
  46. cout<<"1 x ";
  47. vector<int> v=primefactor(x);
  48. for(int i=0;i<v.size();i++)
  49. {
  50. if(i==v.size()-1)
  51. cout<<v[i];
  52. else
  53. cout<<i<<" x ";
  54. }
  55. }
  56. cout<<"\n";
  57.  
  58. }
  59.  
  60.  
  61. }
  62.  
Success #stdin #stdout 0s 4372KB
stdin
Standard input is empty
stdout
Standard output is empty