結果

問題 No.2074 Product is Square ?
ユーザー とりゐとりゐ
提出日時 2022-09-16 21:44:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 528 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 77,528 KB
最終ジャッジ日時 2023-08-23 14:44:50
合計ジャッジ時間 9,948 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,260 KB
testcase_01 AC 92 ms
76,428 KB
testcase_02 AC 91 ms
76,760 KB
testcase_03 AC 93 ms
76,812 KB
testcase_04 AC 89 ms
76,896 KB
testcase_05 AC 91 ms
76,816 KB
testcase_06 AC 92 ms
76,888 KB
testcase_07 AC 92 ms
76,456 KB
testcase_08 AC 93 ms
77,152 KB
testcase_09 AC 93 ms
76,672 KB
testcase_10 AC 92 ms
76,892 KB
testcase_11 AC 329 ms
76,532 KB
testcase_12 AC 306 ms
76,532 KB
testcase_13 AC 528 ms
77,280 KB
testcase_14 AC 339 ms
76,720 KB
testcase_15 AC 331 ms
76,700 KB
testcase_16 AC 316 ms
76,472 KB
testcase_17 AC 526 ms
77,528 KB
testcase_18 AC 343 ms
76,704 KB
testcase_19 AC 287 ms
76,460 KB
testcase_20 AC 270 ms
76,480 KB
testcase_21 AC 527 ms
77,348 KB
testcase_22 AC 310 ms
76,748 KB
testcase_23 AC 298 ms
76,752 KB
testcase_24 AC 308 ms
76,732 KB
testcase_25 AC 391 ms
76,508 KB
testcase_26 AC 262 ms
76,720 KB
testcase_27 AC 331 ms
76,716 KB
testcase_28 AC 316 ms
76,836 KB
testcase_29 AC 349 ms
76,956 KB
testcase_30 AC 272 ms
76,676 KB
testcase_31 AC 79 ms
75,732 KB
testcase_32 AC 71 ms
71,508 KB
testcase_33 AC 97 ms
76,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

def floor_sqrt(n):
  if n<0:
    return -1
  ng,ok=n+1,-1
  while ng-ok>1:
    mid=(ok+ng)//2
    if mid*mid<=n:
      ok=mid
    else:
      ng=mid
  return ok

def solve():
  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 g!=1:
        a[i]//=g
        a[j]//=g
    
    if a[i]!=1:
      s=floor_sqrt(a[i])
      if s*s!=a[i]:
        print('No')
        return

  print('Yes')

for _ in range(int(input())):
  solve()  
0