結果

問題 No.2074 Product is Square ?
ユーザー HIcoderHIcoder
提出日時 2023-07-15 20:24:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,329 bytes
コンパイル時間 2,586 ms
コンパイル使用メモリ 118,340 KB
実行使用メモリ 7,964 KB
最終ジャッジ日時 2023-10-17 06:29:03
合計ジャッジ時間 7,561 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/*

*/
#include<iostream>
#include<set> 
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include <unordered_set>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=998244353;

void solve(){
    ll N;
    cin>>N;
    vector<ll> A(N);
    for(int i=0;i<N;i++)cin>>A[i];
    const int maxT=2*10000;
    vector<ll> cnt(maxT+1,0);

    map<ll,ll> mp;

    for(int i=0;i<N;i++){
        for(int t=2;t<=maxT;t++){
            while(A[i]%t==0){
                cnt[t]++;
                A[i]/=t;
            }
        }

        if(A[i]>1){
            for(ll t=maxT;t*t<=A[i];t++){
                while(A[i]%t==0){
                    mp[t]++;
                    A[i]/=t;
                }
            }
        }
        if(A[i]>1){
            mp[A[i]]++;
            A[i]/=A[i];
        }
    }



    bool flag=true;
    for(int t=2;t<=maxT;t++){
        if(cnt[t]%2!=0){
            flag=false;
        }
    }

    if(flag){
        for(auto [v,num]:mp){
            if(num%2!=0){
                flag=false;
            }
        }
    }



    cout<<(flag?"Yes":"No")<<endl;


}

int main(){
    int T;
    cin>>T;

    for(int t=0;t<T;t++){
        solve();
    }

}
0