結果

問題 No.385 カップ麺生活
ユーザー ebicochineal
提出日時 2016-07-02 00:22:41
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 569 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 20,108 KB
最終ジャッジ日時 2024-10-12 01:40:56
合計ジャッジ時間 4,469 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 3 TLE * 1 -- * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime(n): 
    l = [2, 3]
    if n < 5 : return l 
    for i in range(5, n+1, 2):
        if all([0 if i % x == 0 else 1 for x in l]):
            l += [i]
    return l

M = int(input())
N = int(input())
C = list(map(int, input().split()))
p = set(prime(M))
ans = M // min(C)
q = [0]
cnt = 0
d = {}
while q:
    cnt += 1
    l = []
    for i in set(q):
        for j in C:
            a = i + j
            if a <= M:
                 l += [a]
                 if M - a in p:
                    d[M - a] = cnt
    q = l
for i in d.values():
    ans += i
print(ans)
0