結果
| 問題 |
No.385 カップ麺生活
|
| ユーザー |
ebicochineal
|
| 提出日時 | 2016-07-02 19:35:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 857 bytes |
| コンパイル時間 | 192 ms |
| コンパイル使用メモリ | 82,076 KB |
| 実行使用メモリ | 223,108 KB |
| 最終ジャッジ日時 | 2024-10-12 01:16:13 |
| 合計ジャッジ時間 | 7,824 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 TLE * 1 -- * 10 |
ソースコード
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
def main():
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
l = [0] * (M + sum(C))
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
s = set(filter(lambda x : x <= M, q))
q = []
for i in s:
for j in C_:
a = i + j
q += [a]
l[M - a] = cnt
for i in range(M):
if i+1 in p : ans += l[i+1]
print(ans)
if __name__ == '__main__':
main()
ebicochineal