結果

問題 No.2074 Product is Square ?
ユーザー 👑 KazunKazun
提出日時 2022-09-16 22:50:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 505 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 78,604 KB
最終ジャッジ日時 2023-08-23 16:22:08
合計ジャッジ時間 11,345 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
71,908 KB
testcase_01 AC 125 ms
77,920 KB
testcase_02 AC 120 ms
77,672 KB
testcase_03 AC 123 ms
77,828 KB
testcase_04 AC 123 ms
77,952 KB
testcase_05 AC 120 ms
77,468 KB
testcase_06 AC 123 ms
77,784 KB
testcase_07 AC 121 ms
78,012 KB
testcase_08 AC 119 ms
78,092 KB
testcase_09 AC 125 ms
77,888 KB
testcase_10 AC 122 ms
77,816 KB
testcase_11 AC 383 ms
78,400 KB
testcase_12 AC 355 ms
77,952 KB
testcase_13 AC 501 ms
78,396 KB
testcase_14 AC 376 ms
78,476 KB
testcase_15 AC 386 ms
78,136 KB
testcase_16 AC 356 ms
77,840 KB
testcase_17 AC 504 ms
78,380 KB
testcase_18 AC 390 ms
78,352 KB
testcase_19 AC 390 ms
78,372 KB
testcase_20 AC 363 ms
77,924 KB
testcase_21 AC 502 ms
78,380 KB
testcase_22 AC 385 ms
77,672 KB
testcase_23 AC 385 ms
78,380 KB
testcase_24 AC 353 ms
77,804 KB
testcase_25 AC 505 ms
78,604 KB
testcase_26 AC 382 ms
78,168 KB
testcase_27 AC 376 ms
77,936 KB
testcase_28 AC 354 ms
78,460 KB
testcase_29 AC 504 ms
78,388 KB
testcase_30 AC 385 ms
78,040 KB
testcase_31 AC 91 ms
72,440 KB
testcase_32 AC 88 ms
71,668 KB
testcase_33 AC 141 ms
78,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from math import isqrt,gcd
#==================================================
def is_square(x):
    y=isqrt(x)
    return y*y==x

def solve():
    N=int(input())
    A=list(map(int,input().split()))

    for i in range(N):
        if is_square(A[i]):
            A[i]=1

    for i in range(N):
        for j in range(i+1,N):
            g=gcd(A[i], A[j])
            A[i]//=g
            A[j]//=g

    return all([is_square(a) for a in A])

#==================================================
T=int(input())
for _ in range(T):
    print("Yes" if solve() else "No")
0