結果

問題 No.2074 Product is Square ?
ユーザー 👑 rin204rin204
提出日時 2022-09-16 21:37:42
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 537 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 421 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 77,456 KB
最終ジャッジ日時 2023-08-23 14:36:49
合計ジャッジ時間 10,302 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,548 KB
testcase_01 AC 94 ms
76,932 KB
testcase_02 AC 95 ms
77,404 KB
testcase_03 AC 92 ms
77,456 KB
testcase_04 AC 94 ms
76,896 KB
testcase_05 AC 91 ms
76,624 KB
testcase_06 AC 93 ms
76,792 KB
testcase_07 AC 88 ms
76,492 KB
testcase_08 AC 91 ms
76,628 KB
testcase_09 AC 92 ms
76,836 KB
testcase_10 AC 88 ms
76,724 KB
testcase_11 AC 307 ms
76,960 KB
testcase_12 AC 325 ms
76,952 KB
testcase_13 AC 535 ms
76,952 KB
testcase_14 AC 342 ms
76,652 KB
testcase_15 AC 305 ms
76,960 KB
testcase_16 AC 329 ms
76,956 KB
testcase_17 AC 537 ms
76,556 KB
testcase_18 AC 350 ms
76,776 KB
testcase_19 AC 270 ms
76,828 KB
testcase_20 AC 284 ms
76,516 KB
testcase_21 AC 537 ms
76,744 KB
testcase_22 AC 322 ms
76,948 KB
testcase_23 AC 273 ms
76,744 KB
testcase_24 AC 325 ms
76,520 KB
testcase_25 AC 406 ms
77,192 KB
testcase_26 AC 262 ms
77,004 KB
testcase_27 AC 299 ms
76,628 KB
testcase_28 AC 328 ms
76,468 KB
testcase_29 AC 355 ms
76,624 KB
testcase_30 AC 279 ms
76,724 KB
testcase_31 AC 79 ms
71,500 KB
testcase_32 AC 74 ms
71,556 KB
testcase_33 AC 102 ms
76,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

def solve():
    n = int(input())
    A = list(map(int, input().split()))
    for i in range(n):
        if A[i] == 1:
            continue
        for j in range(i + 1, n):
            g = gcd(A[i], A[j])
            A[i] //= g
            A[j] //= g
        
        if A[i] != 1:
            x = int(A[i] ** 0.5)
            while x * x >= A[i]:
                x -= 1
            while x * x < A[i]:
                x += 1
            if x * x != A[i]:
                print("No")
                return
            A[i] = 1
    print("Yes")

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