結果

問題 No.2074 Product is Square ?
ユーザー 👑 KazunKazun
提出日時 2022-09-16 22:50:13
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 546 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 253 ms
使用メモリ 82,752 KB
最終ジャッジ日時 2023-01-11 08:08:44
合計ジャッジ時間 12,362 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 94 ms
76,104 KB
testcase_01 AC 138 ms
82,176 KB
testcase_02 AC 138 ms
82,060 KB
testcase_03 AC 140 ms
82,052 KB
testcase_04 AC 138 ms
82,008 KB
testcase_05 AC 135 ms
82,012 KB
testcase_06 AC 140 ms
82,088 KB
testcase_07 AC 140 ms
82,096 KB
testcase_08 AC 137 ms
81,968 KB
testcase_09 AC 138 ms
82,040 KB
testcase_10 AC 136 ms
81,968 KB
testcase_11 AC 404 ms
82,720 KB
testcase_12 AC 383 ms
82,680 KB
testcase_13 AC 546 ms
82,464 KB
testcase_14 AC 409 ms
82,752 KB
testcase_15 AC 403 ms
82,636 KB
testcase_16 AC 386 ms
82,748 KB
testcase_17 AC 536 ms
82,620 KB
testcase_18 AC 412 ms
82,640 KB
testcase_19 AC 404 ms
82,700 KB
testcase_20 AC 381 ms
82,044 KB
testcase_21 AC 541 ms
82,704 KB
testcase_22 AC 409 ms
82,684 KB
testcase_23 AC 406 ms
82,640 KB
testcase_24 AC 376 ms
82,172 KB
testcase_25 AC 538 ms
82,388 KB
testcase_26 AC 409 ms
82,264 KB
testcase_27 AC 406 ms
82,736 KB
testcase_28 AC 386 ms
82,628 KB
testcase_29 AC 534 ms
82,700 KB
testcase_30 AC 409 ms
82,068 KB
testcase_31 AC 103 ms
76,632 KB
testcase_32 AC 96 ms
76,184 KB
testcase_33 AC 172 ms
82,564 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