結果

問題 No.2074 Product is Square ?
ユーザー t98slidert98slider
提出日時 2022-09-16 22:04:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 995 ms / 2,000 ms
コード長 983 bytes
コンパイル時間 1,561 ms
コンパイル使用メモリ 170,640 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 15:38:28
合計ジャッジ時間 10,330 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 6 ms
4,376 KB
testcase_02 AC 6 ms
4,376 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 7 ms
4,380 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 6 ms
4,380 KB
testcase_11 AC 96 ms
4,376 KB
testcase_12 AC 223 ms
4,376 KB
testcase_13 AC 993 ms
4,380 KB
testcase_14 AC 190 ms
4,376 KB
testcase_15 AC 93 ms
4,376 KB
testcase_16 AC 229 ms
4,376 KB
testcase_17 AC 995 ms
4,376 KB
testcase_18 AC 196 ms
4,376 KB
testcase_19 AC 95 ms
4,380 KB
testcase_20 AC 226 ms
4,376 KB
testcase_21 AC 993 ms
4,380 KB
testcase_22 AC 192 ms
4,376 KB
testcase_23 AC 97 ms
4,380 KB
testcase_24 AC 224 ms
4,376 KB
testcase_25 AC 986 ms
4,376 KB
testcase_26 AC 192 ms
4,376 KB
testcase_27 AC 92 ms
4,380 KB
testcase_28 AC 225 ms
4,380 KB
testcase_29 AC 991 ms
4,376 KB
testcase_30 AC 193 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 3 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    int T;
    cin >> T;
    //vが平方数であるか
    auto f = [&](ll v){
        if(v == 1)return true;
        ll ng = 1, ok = 1000000000, mid;
        while(ng + 1 < ok){
            mid = (ng + ok) / 2;
            if(mid * mid >= v)ok = mid;
            else ng = mid;
        }
        return (ok * ok == v);
    };
    while(T--){
        int n;
        cin >> n;
        vector<ll> a(n);
        for(auto &&v:a)cin >> v;
        sort(a.begin(), a.end());
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i == j)continue;
                ll g = __gcd(a[i], a[j]);
                a[i] /= g, a[j] /= g;
            }
        }
        bool ans = true;
        for(int i = 0; i < n; i++){
            if(!f(a[i])){
                ans = false;
                break;
            }
        }
        cout << (ans ? "Yes" : "No") << '\n';
    }
}
0