結果

問題 No.2074 Product is Square ?
ユーザー rin204rin204
提出日時 2022-09-16 21:37:42
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 535 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 242 ms
使用メモリ 81,912 KB
最終ジャッジ日時 2023-01-11 06:13:01
合計ジャッジ時間 10,000 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 68 ms
76,272 KB
testcase_01 AC 87 ms
81,668 KB
testcase_02 AC 92 ms
81,912 KB
testcase_03 AC 90 ms
81,732 KB
testcase_04 AC 89 ms
81,616 KB
testcase_05 AC 86 ms
81,316 KB
testcase_06 AC 87 ms
81,536 KB
testcase_07 AC 85 ms
81,540 KB
testcase_08 AC 87 ms
81,452 KB
testcase_09 AC 88 ms
81,740 KB
testcase_10 AC 85 ms
81,468 KB
testcase_11 AC 303 ms
81,280 KB
testcase_12 AC 325 ms
81,380 KB
testcase_13 AC 535 ms
81,756 KB
testcase_14 AC 338 ms
81,476 KB
testcase_15 AC 298 ms
81,660 KB
testcase_16 AC 325 ms
81,288 KB
testcase_17 AC 533 ms
81,736 KB
testcase_18 AC 343 ms
81,528 KB
testcase_19 AC 263 ms
81,408 KB
testcase_20 AC 275 ms
81,508 KB
testcase_21 AC 533 ms
81,496 KB
testcase_22 AC 318 ms
81,676 KB
testcase_23 AC 266 ms
81,520 KB
testcase_24 AC 317 ms
81,360 KB
testcase_25 AC 399 ms
81,624 KB
testcase_26 AC 256 ms
81,456 KB
testcase_27 AC 298 ms
81,460 KB
testcase_28 AC 324 ms
81,328 KB
testcase_29 AC 352 ms
81,644 KB
testcase_30 AC 276 ms
81,564 KB
testcase_31 AC 77 ms
76,196 KB
testcase_32 AC 68 ms
76,196 KB
testcase_33 AC 108 ms
81,904 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