結果

問題 No.97 最大の値を求めるくえり
ユーザー mkawa2mkawa2
提出日時 2023-03-16 22:25:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,680 ms / 5,000 ms
コード長 1,654 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 81,808 KB
実行使用メモリ 84,612 KB
最終ジャッジ日時 2023-10-18 13:15:16
合計ジャッジ時間 10,320 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
59,616 KB
testcase_01 AC 58 ms
73,104 KB
testcase_02 AC 506 ms
75,824 KB
testcase_03 AC 503 ms
75,820 KB
testcase_04 AC 91 ms
75,896 KB
testcase_05 AC 100 ms
75,912 KB
testcase_06 AC 112 ms
75,924 KB
testcase_07 AC 139 ms
75,824 KB
testcase_08 AC 179 ms
75,820 KB
testcase_09 AC 390 ms
75,832 KB
testcase_10 AC 421 ms
75,820 KB
testcase_11 AC 582 ms
75,820 KB
testcase_12 AC 742 ms
75,820 KB
testcase_13 AC 900 ms
75,780 KB
testcase_14 AC 1,680 ms
75,992 KB
testcase_15 AC 178 ms
76,120 KB
testcase_16 AC 170 ms
76,296 KB
testcase_17 AC 175 ms
80,916 KB
testcase_18 AC 171 ms
84,612 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

md = 100003
xor128_x = 123456789
xor128_y = 362436069
xor128_z = 521288629
xor128_w = 88675123
mask = (1 << 32)-1

def xor128():
    global xor128_w, xor128_y, xor128_x, xor128_z
    t = xor128_x ^ (xor128_x << 11) & mask
    xor128_x = xor128_y
    xor128_y = xor128_z
    xor128_z = xor128_w
    xor128_w = xor128_w ^ (xor128_w >> 19) ^ (t ^ (t >> 8))
    return xor128_w

n, q = LI()
aa = set(xor128()%md for _ in range(n))
n = len(aa)

if n**3 < md*q:
    for _ in range(q):
        b = II()
        ans = 0
        if b%md:
            for a in aa:
                v = a*b%md
                if v > ans: ans = v
        print(ans)

else:
    for _ in range(q):
        b = II()
        if b%md == 0:
            print(0)
        else:
            b = pow(b, md-2, md)
            for ans in range(md)[::-1]:
                a = ans*b%md
                if a in aa:
                    print(ans)
                    break
0