fork download
  1. /*
  2. * @Author: hungeazy
  3. * @Date: 2026-03-04 23:24:15
  4. * @Last Modified by: hungeazy
  5. * @Last Modified time: 2026-04-02 22:43:33
  6. */
  7. #include <bits/stdc++.h>
  8. using namespace std;
  9. const int N = (int)1e6+10;
  10. int n,q,minPrime[N];
  11.  
  12. void sang()
  13. {
  14. for (int i = 2; i <= N-10; i++)
  15. if (minPrime[i] == 0)
  16. for (int j = i; j <= N-10; j += i)
  17. minPrime[j] = i;
  18. }
  19.  
  20. int main()
  21. {
  22. ios_base::sync_with_stdio(false);
  23. cin.tie(NULL); cout.tie(NULL);
  24. sang();
  25. cin >> q;
  26. while (q--)
  27. {
  28. cin >> n;
  29. vector<int> vec;
  30. while (n != 1)
  31. {
  32. int p = minPrime[n];
  33. while (n%p == 0) n /= p;
  34. vec.push_back(p);
  35. }
  36. sort(vec.begin(),vec.end());
  37. for (int x : vec) cout << x << " ";
  38. cout << endl;
  39. }
  40. }
Success #stdin #stdout 0.01s 7404KB
stdin
Standard input is empty
stdout
Standard output is empty