結果

問題 No.2074 Product is Square ?
ユーザー chineristACchineristAC
提出日時 2022-09-14 09:48:28
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 595 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 251 ms
使用メモリ 85,776 KB
最終ジャッジ日時 2023-01-07 22:41:26
合計ジャッジ時間 12,978 ms
ジャッジサーバーID
(参考情報)
judge16 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 116 ms
78,440 KB
testcase_01 AC 136 ms
83,492 KB
testcase_02 AC 132 ms
83,668 KB
testcase_03 AC 134 ms
83,600 KB
testcase_04 AC 133 ms
83,664 KB
testcase_05 AC 132 ms
83,684 KB
testcase_06 AC 139 ms
83,352 KB
testcase_07 AC 130 ms
83,428 KB
testcase_08 AC 130 ms
83,400 KB
testcase_09 AC 132 ms
83,316 KB
testcase_10 AC 132 ms
83,532 KB
testcase_11 AC 405 ms
83,776 KB
testcase_12 AC 385 ms
83,584 KB
testcase_13 AC 591 ms
85,776 KB
testcase_14 AC 409 ms
83,648 KB
testcase_15 AC 410 ms
83,652 KB
testcase_16 AC 391 ms
83,528 KB
testcase_17 AC 595 ms
85,600 KB
testcase_18 AC 412 ms
83,628 KB
testcase_19 AC 405 ms
83,512 KB
testcase_20 AC 384 ms
83,640 KB
testcase_21 AC 589 ms
85,488 KB
testcase_22 AC 413 ms
83,616 KB
testcase_23 AC 410 ms
83,508 KB
testcase_24 AC 387 ms
83,676 KB
testcase_25 AC 583 ms
83,740 KB
testcase_26 AC 415 ms
83,588 KB
testcase_27 AC 403 ms
83,620 KB
testcase_28 AC 383 ms
83,652 KB
testcase_29 AC 580 ms
83,784 KB
testcase_30 AC 417 ms
83,700 KB
testcase_31 AC 118 ms
78,476 KB
testcase_32 AC 118 ms
78,488 KB
testcase_33 AC 152 ms
85,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

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

def solve(N,A):
    for i in range(N):
        for j in range(i+1,N):
            g = gcd(A[i],A[j])
            A[i] //= g
            A[j] //= g
    
    for a in A:
        t = int(a**.5)
        for s in range(t-2,t+2):
            if s**2 == a:
                break
        else:
            return False
    return True

for _ in range(int(input())):
    N = int(input())
    A = li()
    print("Yes" if solve(N,A) else "No")
0