結果

問題 No.2074 Product is Square ?
ユーザー umezo
提出日時 2022-09-17 14:02:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 204,088 KB
最終ジャッジ日時 2025-02-07 11:18:43
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 23 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

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

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  vector<int> B={3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,
                83,89,97};
  int a=B.size();
  vector<set<int>> C(a);
  rep(i,a){
    int j=0;
    while(C[i].size()<(B[i]+1)/2){
      C[i].insert(j*j%B[i]);
      j++;
    }
  }

  int t;
  cin>>t;
  while(t--){
    int n;
    cin>>n;
    vector<ll> A(n);
    rep(i,n) cin>>A[i];
    
    bool b=true;
    rep(i,a){
      ll tmp=1;
      rep(j,n) tmp=tmp*(A[j]%B[i])%B[i];
      if(C[i].count(tmp)==0) b=false;
    }
    if(b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  
  return 0;
}
0