結果
| 問題 | No.2074 Product is Square ? | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-09-16 21:47:32 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 490 ms / 2,000 ms | 
| コード長 | 673 bytes | 
| コンパイル時間 | 1,538 ms | 
| コンパイル使用メモリ | 169,856 KB | 
| 実行使用メモリ | 6,820 KB | 
| 最終ジャッジ日時 | 2024-12-21 18:59:41 | 
| 合計ジャッジ時間 | 6,794 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 33 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t; cin >> t;
    while (t--) {
        int n; cin >> n;
        vector<long long> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
            for (int j = 0; j < i; j++) {
                long long g = __gcd(a[i], a[j]);
                a[i] /= g; a[j] /= g;
            }
        }
        bool ok = true;
        for (int i = 0; i < n; i++) {
            int x = round(sqrt(a[i]));
            if (1LL * x * x != a[i]) {
                ok = false;
            }
        }
        cout << (ok ? "Yes\n" : "No\n");
    }
}
            
            
            
        