/* -*- coding: utf-8 -*- * * 2074.cc: No.2074 Product is Square ? - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 1000; /* typedef */ typedef long long ll; /* global variables */ ll as[MAX_N]; /* subroutines */ template T gcd(T m, T n) { // m >= 0, n >= 0 if (m < n) swap(m, n); while (n > 0) { T r = m % n; m = n; n = r; } return m; } bool is_square(ll a) { long double x = floorl(sqrtl((long double)a + 0.5)); return a == x * x; } /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%lld", as + i); int m = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m && as[i] > 1; j++) { ll g = gcd(as[j], as[i]); as[j] /= g, as[i] /= g; } int k = 0; for (int j = 0; j < m; j++) if (as[j] > 1) as[k++] = as[j]; if (as[i] > 1) as[k++] = as[i]; m = k; } bool ok = true; for (int i = 0; ok && i < m; i++) ok = is_square(as[i]); if (ok) puts("Yes"); else puts("No"); //printf("%d:", m); //for (int i = 0; i < m; i++) printf(" %lld", as[i]); putchar('\n'); } return 0; }