結果

問題 No.458 異なる素数の和
ユーザー _matumo__matumo_
提出日時 2019-05-13 11:47:24
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 362 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 86,700 KB
実行使用メモリ 79,200 KB
最終ジャッジ日時 2023-09-21 10:47:35
合計ジャッジ時間 7,345 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,036 KB
testcase_01 AC 217 ms
76,804 KB
testcase_02 AC 251 ms
76,780 KB
testcase_03 AC 121 ms
76,604 KB
testcase_04 AC 131 ms
76,808 KB
testcase_05 AC 450 ms
77,088 KB
testcase_06 AC 244 ms
76,808 KB
testcase_07 AC 88 ms
76,408 KB
testcase_08 AC 456 ms
76,960 KB
testcase_09 AC 99 ms
76,440 KB
testcase_10 RE -
testcase_11 AC 526 ms
77,604 KB
testcase_12 AC 76 ms
71,644 KB
testcase_13 RE -
testcase_14 AC 76 ms
71,776 KB
testcase_15 RE -
testcase_16 AC 112 ms
76,800 KB
testcase_17 AC 80 ms
75,988 KB
testcase_18 AC 78 ms
75,980 KB
testcase_19 AC 81 ms
71,512 KB
testcase_20 AC 81 ms
76,024 KB
testcase_21 AC 77 ms
71,640 KB
testcase_22 AC 76 ms
71,300 KB
testcase_23 AC 81 ms
75,796 KB
testcase_24 AC 83 ms
76,192 KB
testcase_25 AC 76 ms
71,740 KB
testcase_26 AC 79 ms
75,828 KB
testcase_27 AC 242 ms
76,960 KB
testcase_28 AC 519 ms
77,952 KB
testcase_29 AC 93 ms
76,400 KB
testcase_30 AC 180 ms
77,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
pa = [i for i in range(5, N+1, 2) if i % 3]
pr = [2, 3]
rN = int(N**0.5)
while True:
    m = pa[0]
    if m > rN:
        break
    pr += [m]
    pa = [n for n in pa[1:] if n % m]
pr += pa
pa = [1]+[0]*N
for r in pr:
    for j in range(N,-1,-1):
        if pa[j]>0 and j+r<=N:
            pa[j+r]=max(pa[j+r],pa[j]+1)
print(pa[N]-1)            
0