結果

問題 No.2074 Product is Square ?
ユーザー suisui
提出日時 2022-09-16 22:39:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,786 bytes
コンパイル時間 4,414 ms
コンパイル使用メモリ 267,992 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-23 16:14:48
合計ジャッジ時間 5,862 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (int)(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<int,int>;
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

vector<P> prime_factorization(ll n) {
    vector<P> res;
    for(ll p = 2; p * p <= n; p++){
        if(n % p != 0){
            continue;
        }
        int e=0;
        while (n % p == 0){
            e++;
            n /= p;
        }
        res.push_back({p,e});
    }
    if (n != 1) {
        res.push_back({n,1});
    }
    return res;
}

int main(){
    int quary;
    cin >> quary;
    rep(_,quary){
        map<int, int> prime_cnt;
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i,n) cin >> a[i];
        rep(i,n){
            auto pf = prime_factorization(a[i]);
            for(auto p:pf){
                prime_cnt[p.first] += p.second;
            }
        }
        bool ok = true;
        for(auto p:prime_cnt){
            if(p.second % 2 != 0){
                ok = false;
                break;
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
    return 0;
}
0