結果

問題 No.2074 Product is Square ?
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-09-17 10:20:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 530 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 605 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 77,804 KB
最終ジャッジ日時 2023-08-23 17:33:06
合計ジャッジ時間 9,866 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,804 KB
testcase_01 AC 103 ms
77,172 KB
testcase_02 AC 97 ms
77,340 KB
testcase_03 AC 96 ms
77,232 KB
testcase_04 AC 97 ms
77,156 KB
testcase_05 AC 95 ms
77,408 KB
testcase_06 AC 95 ms
77,340 KB
testcase_07 AC 95 ms
77,348 KB
testcase_08 AC 95 ms
77,308 KB
testcase_09 AC 93 ms
77,052 KB
testcase_10 AC 97 ms
77,152 KB
testcase_11 AC 214 ms
77,340 KB
testcase_12 AC 286 ms
77,380 KB
testcase_13 AC 526 ms
77,248 KB
testcase_14 AC 284 ms
77,344 KB
testcase_15 AC 212 ms
77,428 KB
testcase_16 AC 291 ms
77,108 KB
testcase_17 AC 530 ms
77,516 KB
testcase_18 AC 282 ms
76,996 KB
testcase_19 AC 209 ms
77,240 KB
testcase_20 AC 286 ms
77,172 KB
testcase_21 AC 525 ms
77,352 KB
testcase_22 AC 282 ms
77,144 KB
testcase_23 AC 212 ms
77,196 KB
testcase_24 AC 291 ms
76,956 KB
testcase_25 AC 523 ms
77,280 KB
testcase_26 AC 279 ms
77,348 KB
testcase_27 AC 214 ms
77,280 KB
testcase_28 AC 292 ms
77,376 KB
testcase_29 AC 525 ms
76,968 KB
testcase_30 AC 281 ms
77,160 KB
testcase_31 AC 77 ms
71,624 KB
testcase_32 AC 75 ms
71,744 KB
testcase_33 AC 114 ms
77,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def solve():
    n = int(input())
    A = list(map(int,input().split()))
    for i in range(n):
        for j in range(i):
            g = math.gcd(A[i],A[j])
            A[i] //= g
            A[j] //= g

    
    for a in A:
        square = int(a**0.5)
        ok = 0
        for i in range(max(0,square-1),square+2):
            if i**2 == a:
                ok = 1
        if ok == 0:
            return "No"

    return "Yes"

t = int(input())
for _ in range(t):
    print(solve())
0