func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long mod = 1e9 + 7;   int cnt, n, vis[305], a[305], C[305][305], sum[305];   map<int, int> m;   vector<int> v[305];   int num[305], top;   long long jie[305], ans, f[305][305];   void pre() {     jie[0] = 1;     for (int i = 1; i <= 300; i++) jie[i] = jie[i - 1] * i % mod;     C[0][0] = 1;     for (int i = 1; i <= 300; i++) {       C[i][0] = C[i][i] = 1;       for (int j = 1; j < i; j++) {         C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;       }     }   }   bool check(long long a) {     long long temp = (long long)sqrt(a);     return temp * temp == a;   }   void dfs(int a) {     cnt++;     vis[a] = 1;     for (auto to : v[a]) {       if (vis[to] == 0) dfs(to);     }   }   int main() {     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     pre();     for (int i = 1; i <= n; i++) {       for (int j = i + 1; j <= n; j++) {         if (check((long long)a[i] * a[j])) v[i].push_back(j);       }     }     for (int i = 1; i <= n; i++) {       cnt = 0;       if (vis[i] == 0) {         dfs(i);         num[++top] = cnt;       }     }     for (int i = 1; i <= top; i++) {       sum[i] = sum[i - 1] + num[i];     }     f[0][0] = 1;     for (int i = 1; i <= top; i++) {       for (int j = 0; j <= 1 + sum[i - 1]; j++) {         for (int k = 1; k <= num[i]; k++) {           for (int p = 0; p <= min(k, j); p++) {             f[i][j + num[i] - k - p] =                 (f[i][j + num[i] - k - p] +                  f[i - 1][j] * C[j][p] % mod * C[num[i] - 1][k - 1] % mod *                      C[1 + sum[i - 1] - j][k - p] % mod) %                 mod;           }         }       }     }     ans = f[top][0];     for (int i = 1; i <= top; i++) {       ans = ans * jie[num[i]] % mod;     }     cout << ans << endl;     return 0;   }   