結果

問題 No.2074 Product is Square ?
ユーザー HIcoderHIcoder
提出日時 2023-07-15 20:30:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 516 ms / 2,000 ms
コード長 920 bytes
コンパイル時間 952 ms
コンパイル使用メモリ 107,692 KB
最終ジャッジ日時 2025-02-15 15:08:26
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 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;

ll gcd(ll x,ll y){
    return y==0?x:gcd(y,x%y);
}

void solve(){
    ll N;
    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++){
            ll g=gcd(A[i],A[j]);
            A[i]/=g;
            A[j]/=g;
        }
    }

    bool flag=true;

    for(int i=0;i<N;i++){
        //cout<<"A["<<i<<"]="<<A[i]<<endl;
        ll c=round(sqrt(A[i]));
        if(A[i]!=c*c) flag=false;
    }

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


}

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

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

}
0