結果

問題 No.2074 Product is Square ?
ユーザー Fu_L
提出日時 2024-01-30 00:18:09
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 964 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 195,888 KB
最終ジャッジ日時 2025-02-19 00:43:09
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;
struct SetupIO {
    SetupIO() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout << fixed << setprecision(30);
    }
} setup_io;
int main(void) {
    int T;
    cin >> T;
    while(T--) {
        ll n;
        cin >> n;
        vector<ll> a(n);
        rep(i, 0, n) {
            cin >> a[i];
        }
        rep(i, 0, n) {
            rep(j, i + 1, n) {
                ll g = gcd(a[i], a[j]);
                a[i] /= g;
                a[j] /= g;
            }
        }
        bool flag = true;
        rep(i, 0, n) {
            ll r = sqrtl(a[i]);
            if(r * r != a[i]) flag = false;
        }
        if(flag) {
            cout << "Yes" << '\n';
        } else {
            cout << "No" << '\n';
        }
    }
}
0