結果

問題 No.2074 Product is Square ?
ユーザー とりゐとりゐ
提出日時 2022-09-16 21:44:18
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 539 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 269 ms
使用メモリ 81,712 KB
最終ジャッジ日時 2023-01-11 06:23:33
合計ジャッジ時間 11,055 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 77 ms
75,644 KB
testcase_01 AC 101 ms
80,832 KB
testcase_02 AC 106 ms
80,988 KB
testcase_03 AC 102 ms
81,040 KB
testcase_04 AC 102 ms
80,828 KB
testcase_05 AC 102 ms
80,832 KB
testcase_06 AC 103 ms
80,988 KB
testcase_07 AC 103 ms
81,000 KB
testcase_08 AC 108 ms
81,132 KB
testcase_09 AC 105 ms
80,852 KB
testcase_10 AC 103 ms
80,904 KB
testcase_11 AC 346 ms
80,908 KB
testcase_12 AC 320 ms
81,060 KB
testcase_13 AC 535 ms
81,712 KB
testcase_14 AC 351 ms
80,832 KB
testcase_15 AC 339 ms
81,092 KB
testcase_16 AC 329 ms
80,924 KB
testcase_17 AC 539 ms
81,408 KB
testcase_18 AC 354 ms
80,852 KB
testcase_19 AC 303 ms
80,836 KB
testcase_20 AC 280 ms
80,820 KB
testcase_21 AC 534 ms
81,388 KB
testcase_22 AC 321 ms
80,864 KB
testcase_23 AC 304 ms
80,908 KB
testcase_24 AC 317 ms
81,228 KB
testcase_25 AC 402 ms
81,080 KB
testcase_26 AC 272 ms
80,844 KB
testcase_27 AC 341 ms
81,060 KB
testcase_28 AC 329 ms
80,952 KB
testcase_29 AC 356 ms
81,044 KB
testcase_30 AC 283 ms
80,832 KB
testcase_31 AC 91 ms
80,340 KB
testcase_32 AC 77 ms
75,612 KB
testcase_33 AC 123 ms
81,472 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