結果

問題 No.385 カップ麺生活
ユーザー ebicochinealebicochineal
提出日時 2016-07-02 08:58:14
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 715 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 220,096 KB
最終ジャッジ日時 2024-04-20 07:13:45
合計ジャッジ時間 7,557 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
57,728 KB
testcase_01 AC 42 ms
58,496 KB
testcase_02 AC 37 ms
52,096 KB
testcase_03 AC 42 ms
58,624 KB
testcase_04 AC 102 ms
76,432 KB
testcase_05 AC 42 ms
58,496 KB
testcase_06 AC 62 ms
70,016 KB
testcase_07 AC 86 ms
76,032 KB
testcase_08 AC 59 ms
69,504 KB
testcase_09 AC 38 ms
52,096 KB
testcase_10 AC 119 ms
76,160 KB
testcase_11 AC 37 ms
51,968 KB
testcase_12 AC 74 ms
76,032 KB
testcase_13 AC 277 ms
93,900 KB
testcase_14 AC 919 ms
107,648 KB
testcase_15 AC 99 ms
79,188 KB
testcase_16 AC 45 ms
60,416 KB
testcase_17 AC 585 ms
111,784 KB
testcase_18 AC 57 ms
68,096 KB
testcase_19 AC 58 ms
68,224 KB
testcase_20 AC 133 ms
91,864 KB
testcase_21 AC 201 ms
89,204 KB
testcase_22 AC 264 ms
77,148 KB
testcase_23 AC 148 ms
84,736 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_number_list(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 = sorted(list(map(int, input().split())))
p = set(prime_number_list(M))
ans = M // min(C)
q = [0]
cnt = 0
d = {}
c = [C[0]]
for i in range(1, len(C)):
    if all([0 if C[i] % x == 0 else 1 for x in C[:i]]):
        c += [C[i]]
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