結果

問題 No.1083 余りの余り
ユーザー prd_xxx
提出日時 2020-06-19 21:51:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 394 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 43,216 KB
最終ジャッジ日時 2024-07-03 14:21:07
合計ジャッジ時間 12,064 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 2 TLE * 2 -- * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N,K = map(int,input().split())
A = list(map(int,input().split()))
dp = [None] * (1<<N)
for i,a in enumerate(A):
    dp[1<<i] = K%a

def dfs(b):
    if dp[b] is not None:
        return dp[b]
    ret = 0
    for i,a in enumerate(A):
        if b&(1<<i)==0: continue
        ret = max(ret, dfs(b^(1<<i)) % a)
    dp[b] = ret
    return ret
print(dfs(2**N-1))
0