結果

問題 No.2074 Product is Square ?
ユーザー chineristAC
提出日時 2022-09-14 09:48:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 484 ms / 2,000 ms
コード長 881 bytes
コンパイル時間 250 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 70,912 KB
最終ジャッジ日時 2024-12-14 23:56:55
合計ジャッジ時間 9,561 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

def isqrt(n):
    ok = 0
    ng = n+1
    while ng-ok>1:
        mid = (ok+ng)//2
        if mid*mid <= n:
            ok = mid
        else:
            ng = mid
    return ok

def solve(N,A):
    for i in range(N):
        for j in range(i+1,N):
            g = gcd(A[i],A[j])
            A[i] //= g
            A[j] //= g
    
    for a in A:
        t = int(a**.5)
        for s in range(t-2,t+2):
            if s**2 == a:
                break
        else:
            return False
    return True

for _ in range(int(input())):
    N = int(input())
    A = li()
    print("Yes" if solve(N,A) else "No")
0