Ankit_132

D

Oct 12th, 2023
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8.  
  9. int main()
  10. {
  11.     _test
  12.     {
  13.         int n;
  14.         cin>>n;
  15.  
  16.         vector<ll int> a(n);
  17.         for(auto &e: a)     cin>>e;
  18.  
  19.         map<ll int, int> cnt;
  20.  
  21.         for(auto e: a)
  22.         {
  23.             for(ll int i=2; i*i<=e; i++)
  24.             {
  25.                 while(e%i == 0)
  26.                 {
  27.                     cnt[i]++;
  28.                     e /= i;
  29.                 }
  30.             }
  31.  
  32.             if(e > 1)       cnt[e]++;
  33.         }
  34.  
  35.         int f = 1;
  36.  
  37.         for(auto [x ,y]: cnt)
  38.             f &= (y%n == 0);
  39.  
  40.         if(f)       cout<<"YES\n";
  41.         else        cout<<"NO\n";
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment