fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define f first
  4. #define s second
  5. #define pb push_back
  6. const int mod = 1e9+7;
  7. const long long oo=1e18;
  8. int main() {
  9. ios::sync_with_stdio(false); cin.tie(nullptr);
  10. //freopen("input.txt", "r", stdin);
  11. //freopen("guess.out", "w", stdout);
  12. int size = 10000001;
  13. vector<int>spf(size);
  14. for(int i=0 ; i<size ; i++) spf[i] = i;
  15. for(int i=2 ; i*i < size ; i++){
  16. if(spf[i] == i){
  17. for(int j=i*i ; j<size ; j+=i){
  18. if(spf[j] == j) spf[j] = i;
  19. }
  20. }
  21. }
  22.  
  23. int x;
  24. while(cin>>x){
  25. cout<<1;
  26. while(x > 1){
  27. cout<<" x "<<spf[x];
  28. x/=spf[x];
  29. }
  30. cout<<'\n';
  31. }
  32. }
Success #stdin #stdout 0.14s 42300KB
stdin
Standard input is empty
stdout
Standard output is empty