結果

問題 No.2074 Product is Square ?
ユーザー mkawa2mkawa2
提出日時 2022-09-16 22:32:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,478 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 77,676 KB
最終ジャッジ日時 2023-08-23 16:09:03
合計ジャッジ時間 5,079 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
76,020 KB
testcase_01 AC 95 ms
77,444 KB
testcase_02 AC 94 ms
77,364 KB
testcase_03 AC 95 ms
77,368 KB
testcase_04 AC 95 ms
77,496 KB
testcase_05 AC 96 ms
77,656 KB
testcase_06 AC 96 ms
77,516 KB
testcase_07 AC 94 ms
77,460 KB
testcase_08 AC 96 ms
77,460 KB
testcase_09 AC 96 ms
77,496 KB
testcase_10 AC 95 ms
77,460 KB
testcase_11 AC 94 ms
77,476 KB
testcase_12 AC 91 ms
76,760 KB
testcase_13 AC 95 ms
77,532 KB
testcase_14 AC 92 ms
76,672 KB
testcase_15 AC 91 ms
76,876 KB
testcase_16 AC 91 ms
76,908 KB
testcase_17 AC 96 ms
77,380 KB
testcase_18 AC 92 ms
76,812 KB
testcase_19 AC 96 ms
77,676 KB
testcase_20 WA -
testcase_21 AC 95 ms
77,436 KB
testcase_22 WA -
testcase_23 AC 98 ms
77,464 KB
testcase_24 WA -
testcase_25 AC 96 ms
77,416 KB
testcase_26 AC 91 ms
76,916 KB
testcase_27 AC 93 ms
77,380 KB
testcase_28 AC 89 ms
76,768 KB
testcase_29 AC 94 ms
77,384 KB
testcase_30 AC 91 ms
76,860 KB
testcase_31 AC 83 ms
76,308 KB
testcase_32 AC 77 ms
76,288 KB
testcase_33 AC 93 ms
76,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

pp = [256, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107,
      109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233,
      239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293]

pn = len(pp)
rr = []
for p in pp:
    st = set()
    for a in range(p+5):
        st.add(a**2%p)
    rr.append(st)

def solve():
    def ok():
        for i, s in enumerate(ss):
            if s not in rr[i]: return False
        return True

    n = II()
    aa = LI()
    ss = [1]*pn
    for a in aa:
        for i, m in enumerate(pp):
            ss[i] *= a
            ss[i] %= m
    print("Yes" if ok() else "No")

for _ in range(II()):
    solve()
0