結果

問題 No.2074 Product is Square ?
ユーザー mkawa2mkawa2
提出日時 2022-09-16 22:33:42
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 2,036 bytes
コンパイル時間 693 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 78,728 KB
最終ジャッジ日時 2023-08-23 16:09:52
合計ジャッジ時間 5,056 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
75,992 KB
testcase_01 AC 103 ms
77,844 KB
testcase_02 AC 104 ms
77,956 KB
testcase_03 AC 105 ms
77,828 KB
testcase_04 AC 107 ms
78,336 KB
testcase_05 AC 104 ms
77,916 KB
testcase_06 AC 105 ms
77,724 KB
testcase_07 AC 105 ms
78,192 KB
testcase_08 AC 106 ms
78,076 KB
testcase_09 AC 105 ms
77,980 KB
testcase_10 AC 110 ms
78,728 KB
testcase_11 AC 102 ms
77,980 KB
testcase_12 AC 97 ms
77,824 KB
testcase_13 AC 105 ms
78,052 KB
testcase_14 AC 102 ms
78,116 KB
testcase_15 AC 102 ms
77,704 KB
testcase_16 AC 98 ms
77,824 KB
testcase_17 AC 108 ms
77,948 KB
testcase_18 AC 102 ms
77,744 KB
testcase_19 AC 103 ms
77,760 KB
testcase_20 AC 100 ms
77,824 KB
testcase_21 AC 105 ms
77,804 KB
testcase_22 AC 101 ms
77,724 KB
testcase_23 AC 104 ms
77,840 KB
testcase_24 AC 101 ms
77,832 KB
testcase_25 AC 108 ms
78,272 KB
testcase_26 AC 103 ms
78,088 KB
testcase_27 AC 104 ms
77,820 KB
testcase_28 AC 101 ms
78,184 KB
testcase_29 AC 108 ms
77,872 KB
testcase_30 AC 102 ms
77,876 KB
testcase_31 AC 82 ms
76,052 KB
testcase_32 AC 78 ms
75,680 KB
testcase_33 AC 99 ms
76,452 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 = [2, 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, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373,
      379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509,
      521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659,
      661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823,
      827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983,
      991, 997]

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