結果

問題 No.2074 Product is Square ?
ユーザー rlangevinrlangevin
提出日時 2023-08-04 00:18:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 630 bytes
コンパイル時間 193 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 70,784 KB
最終ジャッジ日時 2024-04-21 22:54:06
合計ジャッジ時間 8,860 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,096 KB
testcase_01 AC 75 ms
64,640 KB
testcase_02 AC 57 ms
64,896 KB
testcase_03 AC 57 ms
64,896 KB
testcase_04 AC 58 ms
64,768 KB
testcase_05 AC 64 ms
64,640 KB
testcase_06 AC 60 ms
65,024 KB
testcase_07 AC 58 ms
65,024 KB
testcase_08 AC 64 ms
67,328 KB
testcase_09 AC 59 ms
64,640 KB
testcase_10 AC 59 ms
64,640 KB
testcase_11 AC 289 ms
65,792 KB
testcase_12 AC 270 ms
65,920 KB
testcase_13 AC 432 ms
67,200 KB
testcase_14 AC 295 ms
65,792 KB
testcase_15 AC 288 ms
65,920 KB
testcase_16 AC 267 ms
65,664 KB
testcase_17 AC 439 ms
66,944 KB
testcase_18 AC 297 ms
65,792 KB
testcase_19 AC 289 ms
66,176 KB
testcase_20 AC 273 ms
65,792 KB
testcase_21 AC 439 ms
67,072 KB
testcase_22 AC 298 ms
65,920 KB
testcase_23 AC 296 ms
65,920 KB
testcase_24 AC 272 ms
65,664 KB
testcase_25 AC 428 ms
67,200 KB
testcase_26 AC 295 ms
66,432 KB
testcase_27 AC 290 ms
65,792 KB
testcase_28 AC 272 ms
65,664 KB
testcase_29 AC 429 ms
67,200 KB
testcase_30 AC 294 ms
66,432 KB
testcase_31 AC 44 ms
58,368 KB
testcase_32 AC 37 ms
52,224 KB
testcase_33 AC 77 ms
70,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from math import gcd

def is_sqrt(n):
    yes = 0
    no = 10 ** 9 + 5
    while no - yes != 1:
        mid = (yes + no)//2
        if n >= mid * mid:
            yes = mid
        else:
            no = mid
            
    return n == yes * yes
    

T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    for i in range(N):
        for j in range(i + 1, N):
            g = gcd(A[i], A[j])
            A[i] //= g
            A[j] //= g
            
    ans = 1
    for a in A:
        ans &= is_sqrt(a)
    print("Yes") if ans else print("No")
0