Advertisement
esraa_syam

Untitled

Apr 15th, 2023
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.40 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define nl "\n"
  3. #define fi first
  4. #define se second
  5. #define pi 3.14159
  6. #define ll long long
  7. #define odd(a)  (a&1)
  8. #define even(a)  !(a&1)
  9. #define Mod 1'000'000'007
  10. #define INF 2'000'000'000
  11. #define sz(x) int(x.size())
  12. #define charToInt(s) (s - '0')
  13. #define ull unsigned long long
  14. #define number_line iota(all(vec) , 1)
  15. #define all(s) s.begin(), s.end()
  16. #define rall(v) v.rbegin() , v.rend()
  17. #define fixed(n) fixed << setprecision(n)
  18. #define Num_of_Digits(n) ((int)log10(n) + 1)
  19. #define to_decimal(bin) stoll(bin, nullptr, 2)
  20. #define Ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  21. #define Floor(n, m) (((n) / (m)) - ((n) % (m) ? 0 : 1))
  22. #define Upper(s) transform(all(s), s.begin(), ::toupper);
  23. #define Lower(s) transform(all(s), s.begin(), ::tolower);
  24. #define cout_map(mp) for(auto& [f, s] : mp) cout << f << "  " << s << "\n";
  25. //  ----- bits-------
  26. #define pcnt(n) __builtin_popcount(n)  
  27. #define pcntll(n) __builtin_popcountll(n)
  28. #define clz(n) __builtin_clz(n)    // <---100
  29. #define clzll(n) __builtin_clzll(n)
  30. #define ctz(n) __builtin_ctz(n)  // 0001---->
  31. #define ctzll(n) __builtin_ctzll(n)
  32.  
  33. using namespace std;
  34.  
  35. template < typename T = int > istream& operator >> (istream &in, vector < T > & v){
  36.     for(auto & x : v) in >> x;
  37.     return in;
  38. }
  39.  
  40. template < typename T = int > ostream& operator << (ostream &out, const vector < T > & v){
  41.     for(const T & x : v) out << x << " ";
  42.     return out;
  43. }
  44.  
  45. void esraa()
  46. {
  47.     //freopen("shuffle.in", "r", stdin), freopen("shuffle.out", "w", stdout);
  48.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  49. #ifndef ONLINE_JUDGE
  50.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  51. #endif
  52. }
  53. void solve(){
  54.     ll n;
  55.     cin >> n;
  56.     if(n == 1) cout << n << nl;
  57.     else{
  58.         vector < int > ans;
  59.         for(int i = 2 ; i <= 20 ; i++){
  60.             if(n % i == 0){
  61.                 ans.push_back(i);
  62.             }
  63.         }
  64.         if(ans.empty() and n > 20) return void(cout << -1 << nl);
  65.         if(ans.empty() and n <= 20) return void(cout << n << nl);
  66.         int LCM = 1;
  67.         for(auto & x : ans){
  68.             LCM = lcm(LCM , x);
  69.             cout << x << " ";
  70.             if(LCM == n) break;
  71.         }
  72.         cout << nl;
  73.     }
  74.  
  75. }
  76. int main()
  77. {
  78.     esraa();
  79.     int t = 1;
  80.     cin >> t;
  81.     //cin.ignore();
  82.     while(t--)
  83.       solve();
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement