結果

問題 No.2074 Product is Square ?
ユーザー Nzt3
提出日時 2022-09-22 01:45:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 233 ms / 2,000 ms
コード長 572 bytes
コンパイル時間 1,642 ms
コンパイル使用メモリ 195,968 KB
最終ジャッジ日時 2025-02-07 13:31:10
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int T;
  cin>>T;
  while(T--){
    int N;
    cin>>N;
    bool ng=false;
    vector<long long>A(N);
    for(auto &i:A)cin>>i;
    for(int i=0;i<N;i++){
      long long p=A[i];
      for(int j=i+1;j<N;j++){
        long long g=gcd(p,A[j]);
        p/=g,A[j]/=g;
      }
      long long sq=sqrt(p);
      bool ngn=true;
      for(long long i=sq-1;i<sq+2;i++){
        if(i*i==p)ngn=false;
      }
      if(ngn)ng=true;
    }
    cout<<(ng?"No\n":"Yes\n");
  }
}
0