SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2.  
  3. //#pragma GCC optimize("O3")
  4. //#pragma GCC target("sse4")
  5.  
  6. #define int long long
  7. #define pb push_back
  8. #define fr first
  9. #define sc second
  10. #define _ << ' ' <<
  11. #define pairs pair<int, int>
  12.  
  13. const int mod = 1e9 + 7;
  14.  
  15. typedef long long ll;
  16. typedef long double ld;
  17.  
  18. using namespace std;
  19.  
  20. void solve(){
  21.     int n;
  22.     cin >> n;
  23.     int a = -1, b = -1;
  24.  
  25.     int i = 2, pos = 1;
  26.  
  27.     while(i * i <= n && n != 1){
  28.         while(n % i == 0){
  29.             if(a == -1){
  30.                 a = i;
  31.             }
  32.             else{
  33.                pos *= i;
  34.                if(pos != a){
  35.                     b = pos;
  36.                     n /= i;
  37.                     break;
  38.                }
  39.             }
  40.             n/=i;
  41.         }
  42.         i++;
  43.     }
  44.     if(a != -1 && b != -1 && a != b && a != n && b != n && n != 1){
  45.         cout << "YES\n";
  46.         cout << a << ' ' << b << ' ' << n << '\n';
  47.     }
  48.     else cout << "NO\n";
  49. }
  50. signed main(){
  51.     ios_base::sync_with_stdio(0);
  52.     cin.tie(0);
  53.     cout.tie(0);
  54.     int t = 1;
  55.     cin >> t;
  56.     while(t--){
  57.         solve();
  58.     }
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top