#line 2 "/home/sakflat/CP/_library/cpp/template/template.cpp" //yukicoder@cpp17 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using P = pair; const ll MOD = 998244353; const ll MODx = 1000000007; const int INF = (1<<30)-1; const ll LINF = (1LL<<62LL)-1; const double EPS = (1e-10); P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}}; P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}}; template vector make_vector(size_t a, T b) { return vector(a, b); } template auto make_vector(size_t a, Ts... ts) { return vector(a, make_vector(ts...)); } /* 確認ポイント cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる 計算量は変わらないが楽できるシリーズ min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる */ /* function corner below */ /* Function corner above */ /* comment outed because can cause bugs __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } */ template T uPow(T z,T n, T mod){ T ans = 1; while(n != 0){ if(n%2){ ans*=z; if(mod)ans%=mod; } n >>= 1; z*=z; if(mod)z%=mod; } return ans; } #line 2 "/home/sakflat/CP/_library/cpp/math/miller-rabin.cpp" /* * true: 素数 * false: 合成数 */ template bool MillerRabinCheck(T n){ if(n == 1)return false; if(n%2 == 0){ return n == 2; } __int128 d = n-1; __int128 s = 0; while(d%2 == 0){ d/=2; s++; } vector<__int128> base = {2,3,5,7,11,13,17,19,23,29,31,37}; for(int i = 0; base.size() > i; i++){ if(base[i] >= n)break; long long current = (long long)uPow(base[i],d,(__int128)n); if(current == 1 || current == n-1)continue; bool ok = false; for(int j = 0; s > j; j++){ current = ((__int128)current * (__int128)current) % n; if(current == n-1){ ok = true; break; } } if(!ok)return false; } return true; } #line 2 "/home/sakflat/CP/_library/cpp/math/rho.cpp" using namespace std; template struct Rho{ mt19937 mt; //32 bit version T N; vector factor; //std::mt19937_64 mt(rnd()); //64 bit version Rho(T n):N(n){ random_device rnd; mt.seed(rnd()); } vector run(){ factor = factors(N); sort(factor.begin(), factor.end()); return factor; } private: __int128 c; T f(__int128 x, T n){ return (x*x + c)%n; } T find_factor(T n){ c = mt()%n; T base = mt()%n; T d = 1; T x = base; T y = base; while(true){ x = f(x, n); y = f(f(y,n),n); d = __gcd(abs(x-y), n); if(d == n){ return -1; }else if(d != 1){ return d; } } } vector factors(T n){ if(n == 1)return {}; if(n == 4)return {2, 2}; if(MillerRabinCheck(n)){ return {n}; } T factor = -1; while(factor == -1){ factor = find_factor(n); } vector f1 = factors(factor); vector f2 = factors(n/factor); f1.insert(f1.end(), f2.begin(), f2.end()); return f1; } }; void solve(){ int n;cin>>n; map Z; for(int i = 0; n > i; i++){ long long x;cin>>x; Rho A(x); A.run(); for(int j = 0; A.factor.size() > j; j++){ Z[A.factor[j]]++; } } for(auto z: Z){ if(z.second%2 != 0){ cout << "No" << endl; return; } } cout << "Yes" << endl; return; } int main(){ int t;cin>>t; for(int i = 0; t > i; i++)solve(); return 0; }