結果
問題 | No.2074 Product is Square ? |
ユーザー |
|
提出日時 | 2023-07-15 20:24:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,332 bytes |
コンパイル時間 | 1,077 ms |
コンパイル使用メモリ | 113,152 KB |
最終ジャッジ日時 | 2025-02-15 15:08:17 |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | TLE * 1 -- * 32 |
ソースコード
/* */ #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*100000; 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+1;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(); } }