結果
問題 | No.2074 Product is Square ? |
ユーザー | ygd. |
提出日時 | 2022-09-16 23:18:59 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,393 bytes |
コンパイル時間 | 489 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 79,940 KB |
最終ジャッジ日時 | 2024-12-21 22:57:04 |
合計ジャッジ時間 | 30,118 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
56,112 KB |
testcase_01 | AC | 732 ms
78,244 KB |
testcase_02 | AC | 699 ms
78,312 KB |
testcase_03 | AC | 701 ms
77,972 KB |
testcase_04 | AC | 706 ms
77,964 KB |
testcase_05 | AC | 752 ms
78,932 KB |
testcase_06 | AC | 740 ms
79,940 KB |
testcase_07 | AC | 740 ms
78,192 KB |
testcase_08 | AC | 694 ms
78,120 KB |
testcase_09 | AC | 694 ms
78,604 KB |
testcase_10 | AC | 671 ms
78,252 KB |
testcase_11 | AC | 192 ms
77,272 KB |
testcase_12 | AC | 676 ms
78,560 KB |
testcase_13 | TLE | - |
testcase_14 | AC | 407 ms
78,076 KB |
testcase_15 | AC | 184 ms
77,484 KB |
testcase_16 | WA | - |
testcase_17 | TLE | - |
testcase_18 | AC | 447 ms
78,212 KB |
testcase_19 | AC | 184 ms
77,504 KB |
testcase_20 | AC | 684 ms
78,252 KB |
testcase_21 | TLE | - |
testcase_22 | AC | 406 ms
78,128 KB |
testcase_23 | AC | 184 ms
77,272 KB |
testcase_24 | AC | 727 ms
79,008 KB |
testcase_25 | TLE | - |
testcase_26 | AC | 424 ms
78,456 KB |
testcase_27 | AC | 177 ms
77,500 KB |
testcase_28 | AC | 713 ms
78,596 KB |
testcase_29 | TLE | - |
testcase_30 | AC | 435 ms
77,936 KB |
testcase_31 | AC | 143 ms
77,096 KB |
testcase_32 | RE | - |
testcase_33 | RE | - |
ソースコード
import sys #input = sys.stdin.readline #input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) import math #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush from collections import defaultdict #from collections import deque #import copy #DeepCopy: hoge = [_[:] for _ in hogehoge] #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] #dx8 = [1,1,0,-1,-1,-1,0,1] #dy8 = [0,1,1,1,0,-1,-1,-1] def gcd(a, b): while b: a, b = b, a % b return a def isPrimeMR(n): d = n - 1 d = d // (d & -d) L = [2] for a in L: t = d y = pow(a, t, n) if y == 1: continue while y != n - 1: y = (y * y) % n if y == 1 or t == n - 1: return 0 t <<= 1 return 1 #無断使用すいません def findFactorRho(n): m = 1 << n.bit_length() // 8 for c in range(1, 99): f = lambda x: (x * x + c) % n y, r, q, g = 2, 1, 1, 1 while g == 1: x = y for i in range(r): y = f(y) k = 0 while k < r and g == 1: ys = y for i in range(min(m, r - k)): y = f(y) q = q * abs(x - y) % n g = gcd(q, n) k += m r <<= 1 if g == n: g = 1 while g == 1: ys = f(ys) g = gcd(abs(x - ys), n) if g < n: if isPrimeMR(g): return g elif isPrimeMR(n // g): return n // g return findFactorRho(g) def primeFactor(n): #これを実行 i = 2 ret = {} rhoFlg = 0 while i * i <= n: k = 0 while n % i == 0: n //= i k += 1 if k: ret[i] = k i += 1 + i % 2 if i == 101 and n >= 2 ** 20: while n > 1: if isPrimeMR(n): ret[n], n = 1, 1 else: rhoFlg = 1 j = findFactorRho(n) k = 0 while n % j == 0: n //= j k += 1 ret[j] = k if n > 1: ret[n] = 1 if rhoFlg: ret = {x: ret[x] for x in sorted(ret)} return ret #高速素因数分解を用いた約数全列挙 import itertools def factorization_fast(x): P = primeFactor(x) base = [] L = [] for p in P: base.append(p) temp = [i for i in range(P[p]+1)] L.append(temp) ret = [] for T in itertools.product(*L): val = 1 for i,t in enumerate(T): val *= pow(base[i],t) ret.append(val) ret.sort() #必要ならソート return ret def main(): T = int(input()) for _ in range(T): N = int(input()) A = list(map(int,input().split())) dic = defaultdict(int) for a in A: PL = primeFactor(a) for p,num in PL.items(): dic[p] ^= num%2 if max(dic.values()) == 0: print('Yes') else: print('No') if __name__ == '__main__': main()