結果

問題 No.97 最大の値を求めるくえり
ユーザー 👑 colognecologne
提出日時 2022-01-31 20:15:20
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,140 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 94,008 KB
最終ジャッジ日時 2023-09-02 02:24:43
合計ジャッジ時間 8,433 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
76,120 KB
testcase_01 AC 81 ms
77,940 KB
testcase_02 RE -
testcase_03 WA -
testcase_04 AC 131 ms
84,208 KB
testcase_05 AC 145 ms
84,876 KB
testcase_06 AC 173 ms
84,364 KB
testcase_07 AC 216 ms
84,932 KB
testcase_08 AC 289 ms
85,256 KB
testcase_09 AC 752 ms
84,488 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def input(): return sys.stdin.readline().rstrip()


def xor128():
    x, y, z, w = 123456789, 362436069, 521288629, 88675123

    while True:
        t = (x ^ (x << 11)) & 0xFFFFFFFF
        x = y
        y = z
        z = w
        w ^= (w >> 19) ^ t ^ (t >> 8)
        yield w


def main():
    N, Q = map(int, input().split())
    qv = [int(input()) for i in range(Q)]

    MOD = 100003

    X = xor128()
    A = [next(X) % MOD for i in range(N)]
    if N**2 < MOD:
        print(*(max(map(lambda x: (x*q) % MOD, A)) for q in qv), sep='\n')
    else:
        cnt = [False]*MOD
        for i in A:
            cnt[i] = True

        ans = {}

        for q in qv:
            if q == 0:
                print(0)
            if q in ans:
                print(ans[q])

            qinv = pow(q, -1, MOD)
            cur = MOD-qinv
            while True:
                if cnt[cur]:
                    ans[q] = cur * q % MOD
                    print(ans[q])
                    break
                else:
                    cur = cur - qinv if cur - qinv > 0 else cur - qinv + MOD


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