結果

問題 No.385 カップ麺生活
ユーザー titiatitia
提出日時 2023-01-28 01:49:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 10,980 KB
最終ジャッジ日時 2023-09-10 18:47:59
合計ジャッジ時間 3,746 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,912 KB
testcase_01 AC 37 ms
10,940 KB
testcase_02 AC 37 ms
10,768 KB
testcase_03 AC 36 ms
10,916 KB
testcase_04 AC 37 ms
10,760 KB
testcase_05 AC 34 ms
10,908 KB
testcase_06 AC 58 ms
10,784 KB
testcase_07 AC 45 ms
10,760 KB
testcase_08 AC 40 ms
10,916 KB
testcase_09 AC 34 ms
10,820 KB
testcase_10 AC 182 ms
10,824 KB
testcase_11 AC 33 ms
10,916 KB
testcase_12 AC 51 ms
10,828 KB
testcase_13 AC 65 ms
10,964 KB
testcase_14 AC 65 ms
10,768 KB
testcase_15 AC 53 ms
10,844 KB
testcase_16 AC 35 ms
10,828 KB
testcase_17 AC 99 ms
10,936 KB
testcase_18 AC 42 ms
10,980 KB
testcase_19 AC 39 ms
10,820 KB
testcase_20 AC 67 ms
10,772 KB
testcase_21 AC 64 ms
10,916 KB
testcase_22 AC 73 ms
10,824 KB
testcase_23 AC 62 ms
10,852 KB
testcase_24 AC 73 ms
10,788 KB
testcase_25 AC 34 ms
10,796 KB
testcase_26 AC 34 ms
10,920 KB
testcase_27 AC 41 ms
10,856 KB
testcase_28 AC 41 ms
10,820 KB
testcase_29 AC 40 ms
10,860 KB
testcase_30 AC 58 ms
10,856 KB
testcase_31 AC 33 ms
10,844 KB
testcase_32 AC 35 ms
10,916 KB
testcase_33 AC 89 ms
10,820 KB
testcase_34 AC 36 ms
10,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

x=50000
import math 
L=math.floor(math.sqrt(x)) # 平方根を求める

Primelist=[i for i in range(x+1)]
Primelist[1]=0 # 1は素数でないので0にする.
 
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0

Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]
SET=set(Primes)

M=int(input())
N=int(input())
C=sorted(map(int,input().split()))

ANS=0

DP=[0]*(M+1)
DP[0]=1
for c in C:
    for i in range(M+1):
        if DP[i]>0 and i+c<=M:
            DP[i+c]=max(DP[i+c],DP[i]+1)

for i in range(M+1):
    if M-i in SET and DP[i]>1:
        ANS+=DP[i]-1

ANS+=M//C[0]

print(ANS)
            

0