fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define nmax 1000010
  5. vector<int> a[nmax];
  6. bool NT[nmax];
  7. int f[nmax];
  8. int q , n , dem = 0;
  9. void sang(){
  10. for (int i = 2 ; i <= nmax ; i++){
  11. if (f[i] == 0){
  12. for (int j = i ; j <= nmax ; j+= i){
  13. f[j] = i;
  14. }
  15. }
  16. }
  17. }
  18. void solve(){
  19. ios::sync_with_stdio(false);
  20. cin.tie(0);
  21. cout.tie(0);
  22. cin >> n;
  23. sang();
  24. for (int i = 1 ; i <= n ; i++){
  25. int x;
  26. set<int> s;
  27. cin >> x;
  28. while(x > 1){
  29. s.insert(f[x]);
  30. x/= f[x];
  31. }
  32. for (int j : s){
  33. cout << j << " ";
  34. }
  35. cout << '\n';
  36. }
  37. }
  38. int main(){
  39. solve();
  40. }
Success #stdin #stdout 0.02s 31900KB
stdin
Standard input is empty
stdout
Standard output is empty