結果

問題 No.2074 Product is Square ?
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2022-09-16 21:47:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,530 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 84,520 KB
最終ジャッジ日時 2023-08-23 14:48:59
合計ジャッジ時間 27,416 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
74,648 KB
testcase_01 AC 1,899 ms
83,392 KB
testcase_02 AC 1,931 ms
83,296 KB
testcase_03 AC 1,846 ms
83,504 KB
testcase_04 AC 1,958 ms
84,212 KB
testcase_05 AC 1,889 ms
83,156 KB
testcase_06 AC 1,989 ms
84,160 KB
testcase_07 AC 1,893 ms
83,988 KB
testcase_08 AC 1,854 ms
83,696 KB
testcase_09 AC 1,842 ms
84,244 KB
testcase_10 WA -
testcase_11 AC 948 ms
82,520 KB
testcase_12 AC 1,828 ms
84,520 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #




from math import gcd
import random
from collections import defaultdict
def is_prime(n):
    if n==2:
        return True
    if n==1 or n&1==0:
        return False
    d=(n-1)>>1
    while d&1==0:
        d>>=1

    for k in range(100):
        a=random.randint(1,n-1)
        t=d
        y=pow(a, t, n)
        while t!=n-1 and y!=1 and y!=n-1:
            y=(y*y)%n
            t<<=1
        if y!=n-1 and t&1==0:
            return False
    return True
def prime_f(x,N):
    return (x*x+1)%N
def prime_fact(N):
    res=defaultdict(int)
    if N==1:
        return res
    p=2
    while(p<=10**4 and N>1):
        if N%p==0:
            while(N%p==0):
                res[p]+=1
                N//=p
        p+=1
    while(N>1):
        if is_prime(N):
            res[N]+=1
            break
        x=random.randrange(N)
        y=prime_f(x,N)
        i=1
        while(True):
            d=gcd(abs(x-y),N)
            if d==1:
                i+=1
            elif d==N:
                res[N]+=1
                return res
            else:
                res[d]+=1
                N//=d
                break
            x=prime_f(x,N)
            y=prime_f(prime_f(y,N),N)
    return res


T=int(input())
from collections import defaultdict
for iii in range(T):
    n=int(input())
    a=list(map(int,input().split()))
    ans=defaultdict(int)
    for x in a:
        pri=prime_fact(x)
        for p in pri:ans[p]+=pri[p]
    flag=1
    for p in ans:
        if ans[p]%2==1:flag=0
    print("Yes" if flag else "No")
0