結果

問題 No.1083 余りの余り
ユーザー hedwig100
提出日時 2020-06-19 22:28:18
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 29 ms / 3,000 ms
コード長 600 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-07-03 15:03:26
合計ジャッジ時間 1,961 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

from collections import deque,defaultdict,Counter
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    A.sort(reverse = True)
    before = defaultdict(int)
    before[K] = 1
    for a in A[:-1]:
        now = defaultdict(int)
        for k in before.keys():
            now[k] = 1
            now[k%a] = 1
        before = now
    now = defaultdict(int)
    for k in before.keys():
        now[k%A[-1]] = 1
    ans = max(now.keys())
    print(ans)
if __name__ == '__main__':
    main()
0