結果

問題 No.2074 Product is Square ?
ユーザー umezoumezo
提出日時 2022-09-17 14:01:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 745 bytes
コンパイル時間 4,024 ms
コンパイル使用メモリ 207,944 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-23 17:42:57
合計ジャッジ時間 4,750 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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};
  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