結果

問題 No.2074 Product is Square ?
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-06-11 05:10:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 226 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 1,239 ms
コンパイル使用メモリ 108,516 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-31 01:44:58
合計ジャッジ時間 6,592 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 4 ms
4,384 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 4 ms
4,384 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,380 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 4 ms
4,376 KB
testcase_11 AC 89 ms
4,376 KB
testcase_12 AC 101 ms
4,376 KB
testcase_13 AC 210 ms
4,376 KB
testcase_14 AC 103 ms
4,380 KB
testcase_15 AC 86 ms
4,384 KB
testcase_16 AC 97 ms
4,380 KB
testcase_17 AC 210 ms
4,380 KB
testcase_18 AC 104 ms
4,376 KB
testcase_19 AC 86 ms
4,380 KB
testcase_20 AC 101 ms
4,380 KB
testcase_21 AC 213 ms
4,376 KB
testcase_22 AC 106 ms
4,376 KB
testcase_23 AC 92 ms
4,376 KB
testcase_24 AC 105 ms
4,376 KB
testcase_25 AC 226 ms
4,380 KB
testcase_26 AC 108 ms
4,376 KB
testcase_27 AC 90 ms
4,380 KB
testcase_28 AC 104 ms
4,380 KB
testcase_29 AC 221 ms
4,380 KB
testcase_30 AC 108 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;

ll isqrt(ll s){
    ll l=0, r=3e9, c;
    while(r-l>1){
        c = (l+r)/2;
        if (c*c <= s) l = c;
        else r = c;
    }
    return l;
}

void solve(){
    ll N, g;
    cin >> N;
    vector<ll> A(N);
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<N; i++){
        for (int j=i+1; j<N; j++){
            g = gcd(A[i], A[j]);
            A[i] /= g; A[j] /= g;
        }
    }
    for (int i=0; i<N; i++){
        g = isqrt(A[i]);
        if (g * g != A[i]){
            cout << "No" << endl;
            return;
        }
    }
    cout << "Yes" << endl;
}

int main(){

    int T;
    cin >> T;
    while(T){
        T--;
        solve();
    }

    return 0;
}
0