結果

問題 No.2074 Product is Square ?
ユーザー suisui
提出日時 2022-09-16 23:36:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 491 ms / 2,000 ms
コード長 1,543 bytes
コンパイル時間 4,223 ms
コンパイル使用メモリ 260,492 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 16:51:15
合計ジャッジ時間 9,681 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 4 ms
4,380 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 4 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 58 ms
4,376 KB
testcase_12 AC 142 ms
4,376 KB
testcase_13 AC 488 ms
4,380 KB
testcase_14 AC 146 ms
4,376 KB
testcase_15 AC 57 ms
4,376 KB
testcase_16 AC 147 ms
4,380 KB
testcase_17 AC 491 ms
4,376 KB
testcase_18 AC 142 ms
4,376 KB
testcase_19 AC 56 ms
4,376 KB
testcase_20 AC 147 ms
4,376 KB
testcase_21 AC 487 ms
4,376 KB
testcase_22 AC 144 ms
4,376 KB
testcase_23 AC 57 ms
4,376 KB
testcase_24 AC 147 ms
4,376 KB
testcase_25 AC 491 ms
4,380 KB
testcase_26 AC 141 ms
4,380 KB
testcase_27 AC 57 ms
4,376 KB
testcase_28 AC 146 ms
4,380 KB
testcase_29 AC 487 ms
4,376 KB
testcase_30 AC 143 ms
4,380 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n+1); i++)
#define repn(i,a,b) for (int i = (int)(a) ; i < (int)(b+1); i++)
#define repv(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define cauto const auto&
#define bit(n) (1LL<<(n))
#define uni(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using P = pair<ll,ll>;
using PP = pair<int, P>;
using Graph = vector<vector<int>>;
using mint = modint998244353;
#ifdef LOCAL
    #include <debug.hpp>
    #define debug(...) debug::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
    #define debug(...) (static_cast<void>(0))
#endif

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int quary;
    cin >> quary;
    rep(_,quary){
        ll n;
        cin >> n;
        vector<ll> a(n);
        rep(i,n) cin >> a[i];
        rep(i,n){
            repn(j,i+1,n-1){
                ll gcd = __gcd(a[i],a[j]);
                if(gcd != 1){
                    a[i] /= gcd;
                    a[j] /= gcd;
                }
            }
        }
        bool ok = true;
        rep(i,n){
            ll s = static_cast<ll> (sqrt(a[i]) + 0.5);
            if(s*s != a[i]){
                ok = false;
                break;
            }
        }
        cout << (ok ? "Yes" : "No") << "\n";
    }
    return 0;
}
0