結果

問題 No.2074 Product is Square ?
ユーザー flygonflygon
提出日時 2022-09-16 23:29:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 536 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 556 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 77,940 KB
最終ジャッジ日時 2023-08-23 16:46:29
合計ジャッジ時間 11,127 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,380 KB
testcase_01 AC 107 ms
77,260 KB
testcase_02 AC 98 ms
77,076 KB
testcase_03 AC 97 ms
77,124 KB
testcase_04 AC 98 ms
77,104 KB
testcase_05 AC 98 ms
77,088 KB
testcase_06 AC 106 ms
77,260 KB
testcase_07 AC 101 ms
77,260 KB
testcase_08 AC 101 ms
77,008 KB
testcase_09 AC 106 ms
77,380 KB
testcase_10 AC 100 ms
77,180 KB
testcase_11 AC 343 ms
77,036 KB
testcase_12 AC 322 ms
77,228 KB
testcase_13 AC 531 ms
77,392 KB
testcase_14 AC 348 ms
77,504 KB
testcase_15 AC 342 ms
76,920 KB
testcase_16 AC 322 ms
77,404 KB
testcase_17 AC 532 ms
77,188 KB
testcase_18 AC 350 ms
77,024 KB
testcase_19 AC 342 ms
77,228 KB
testcase_20 AC 327 ms
77,168 KB
testcase_21 AC 529 ms
77,440 KB
testcase_22 AC 351 ms
77,432 KB
testcase_23 AC 344 ms
76,932 KB
testcase_24 AC 322 ms
77,124 KB
testcase_25 AC 536 ms
77,216 KB
testcase_26 AC 350 ms
76,940 KB
testcase_27 AC 345 ms
77,164 KB
testcase_28 AC 323 ms
77,288 KB
testcase_29 AC 536 ms
77,416 KB
testcase_30 AC 354 ms
77,216 KB
testcase_31 AC 79 ms
71,404 KB
testcase_32 AC 77 ms
71,812 KB
testcase_33 AC 120 ms
77,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd


t = int(input())
for i in range(t):
  n = int(input())
  a = list(map(int,input().split()))
  for i in range(n):
    for j in range(i+1,n):
      g = gcd(a[i], a[j])
      if i == j: continue
      if g == 1: continue
      a[i] //= g
      a[j] //= g
  flg = 1
  for i in range(n):
    if a[i] != 1:
      sq  = int(a[i]**0.5)
      flg2 = 0
      for j in range(max(sq-5,0), sq+5):
        if sq**2 == a[i]:
          flg2 = 1
      if flg2: continue
      flg = 0
  if flg:
    print('Yes')
  else:
    print('No')
0