結果

問題 No.97 最大の値を求めるくえり
ユーザー Mao-betaMao-beta
提出日時 2024-03-07 15:38:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,577 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 91,600 KB
最終ジャッジ日時 2024-03-07 15:39:15
合計ジャッジ時間 14,263 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
63,928 KB
testcase_01 AC 58 ms
80,936 KB
testcase_02 AC 955 ms
79,440 KB
testcase_03 AC 951 ms
79,312 KB
testcase_04 AC 105 ms
77,076 KB
testcase_05 AC 118 ms
77,192 KB
testcase_06 AC 130 ms
77,192 KB
testcase_07 AC 196 ms
77,312 KB
testcase_08 AC 306 ms
77,428 KB
testcase_09 AC 443 ms
77,788 KB
testcase_10 AC 780 ms
79,056 KB
testcase_11 AC 1,108 ms
79,568 KB
testcase_12 AC 1,442 ms
80,208 KB
testcase_13 AC 1,706 ms
81,100 KB
testcase_14 AC 3,403 ms
85,604 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]



xor128_x = 123456789
xor128_y = 362436069
xor128_z = 521288629
xor128_w = 88675123

mask = (1 << 32) - 1

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

def generateA(N):
    A = []
    for i in range(N):
        A.append(xor128() % 100003)
    return A


def main():
    N, Q = NMI()
    M = 100003
    A = generateA(N)
    cutoff = 3000
    if N <= 3000:
        for _ in range(Q):
            q = NI()
            B = [a*q % M for a in A]
            print(max(B))
    else:
        SA = set(A)
        for _ in range(Q):
            q = NI()
            inv = pow(q, M-2, M)
            for x in range(M-1, M-1-3000, -1):
                a = x * inv % M
                if a in SA:
                    print(x)
                    break


if __name__ == "__main__":
    main()
0