結果
問題 | No.2074 Product is Square ? |
ユーザー | ygd. |
提出日時 | 2022-09-16 23:18:59 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,393 bytes |
コンパイル時間 | 364 ms |
コンパイル使用メモリ | 82,396 KB |
実行使用メモリ | 79,568 KB |
最終ジャッジ日時 | 2024-06-01 14:07:36 |
合計ジャッジ時間 | 16,478 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 45 ms
56,556 KB |
testcase_01 | AC | 726 ms
78,596 KB |
testcase_02 | AC | 692 ms
78,252 KB |
testcase_03 | AC | 691 ms
78,336 KB |
testcase_04 | AC | 696 ms
77,936 KB |
testcase_05 | AC | 728 ms
78,732 KB |
testcase_06 | AC | 729 ms
79,568 KB |
testcase_07 | AC | 732 ms
78,208 KB |
testcase_08 | AC | 682 ms
78,080 KB |
testcase_09 | AC | 687 ms
78,336 KB |
testcase_10 | AC | 659 ms
78,336 KB |
testcase_11 | AC | 190 ms
77,824 KB |
testcase_12 | AC | 665 ms
78,592 KB |
testcase_13 | TLE | - |
testcase_14 | AC | 398 ms
78,300 KB |
testcase_15 | AC | 187 ms
77,568 KB |
testcase_16 | WA | - |
testcase_17 | TLE | - |
testcase_18 | AC | 438 ms
78,320 KB |
testcase_19 | AC | 183 ms
77,508 KB |
testcase_20 | AC | 677 ms
78,604 KB |
testcase_21 | TLE | - |
testcase_22 | AC | 404 ms
78,200 KB |
testcase_23 | AC | 181 ms
77,568 KB |
testcase_24 | AC | 711 ms
79,044 KB |
testcase_25 | TLE | - |
testcase_26 | AC | 415 ms
78,160 KB |
testcase_27 | AC | 177 ms
77,652 KB |
testcase_28 | AC | 705 ms
78,280 KB |
testcase_29 | TLE | - |
testcase_30 | AC | 427 ms
78,072 KB |
testcase_31 | AC | 144 ms
76,808 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()