fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. bool allDistinct(vector<int> &v) {
  4. unordered_set<int> st;
  5. for (int x : v) {
  6. if (st.count(x)) return false;
  7. st.insert(x);
  8. }
  9. return true;
  10. }
  11.  
  12. int main() {
  13. int t;
  14. cin>>t;
  15. while(t--){
  16. int n;
  17. cin>>n;
  18. int count=0;
  19. vector<int> f;
  20. for(int i=2;i<=n;i++){
  21. if(n%i==0) {
  22. count++;
  23. f.push_back(i);
  24. }
  25. if(count==2) break;
  26. }
  27. f.push_back(n/(f[0]*f[1]));
  28. if(allDistinct(f) && f[2]>1) cout<<"YES\n"<<f[0]<<" "<<f[1]<<" "<<f[2]<<"\n";
  29. else cout<<"NO\n";
  30. }
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0.01s 5288KB
stdin
5
64
32
97
2
12345
stdout
YES
2 4 8
NO
NO
NO
YES
3 5 823