結果

問題 No.458 異なる素数の和
ユーザー phtmscgphtmscg
提出日時 2019-05-13 18:03:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 363 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 76,776 KB
最終ジャッジ日時 2023-09-22 06:07:16
合計ジャッジ時間 6,598 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
75,816 KB
testcase_01 AC 194 ms
76,488 KB
testcase_02 AC 230 ms
76,428 KB
testcase_03 AC 105 ms
76,396 KB
testcase_04 AC 115 ms
76,148 KB
testcase_05 AC 413 ms
76,684 KB
testcase_06 AC 221 ms
76,512 KB
testcase_07 AC 79 ms
75,880 KB
testcase_08 AC 410 ms
76,776 KB
testcase_09 AC 89 ms
76,248 KB
testcase_10 AC 70 ms
71,588 KB
testcase_11 AC 479 ms
76,728 KB
testcase_12 WA -
testcase_13 AC 70 ms
71,416 KB
testcase_14 AC 70 ms
71,296 KB
testcase_15 WA -
testcase_16 AC 95 ms
76,376 KB
testcase_17 AC 75 ms
75,228 KB
testcase_18 AC 75 ms
75,244 KB
testcase_19 AC 70 ms
71,328 KB
testcase_20 AC 75 ms
75,664 KB
testcase_21 AC 70 ms
71,496 KB
testcase_22 AC 71 ms
71,324 KB
testcase_23 AC 74 ms
75,616 KB
testcase_24 AC 75 ms
75,472 KB
testcase_25 AC 71 ms
71,544 KB
testcase_26 AC 73 ms
75,224 KB
testcase_27 AC 216 ms
76,148 KB
testcase_28 AC 470 ms
76,556 KB
testcase_29 WA -
testcase_30 AC 164 ms
76,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

def dpsum(N):
    if N == 1:
        return -1
    pn = [2]
    for i in range(3,N+1,2):
        for s in pn:
            if i%s == 0:break
        else:pn += [i]
    Q = [1]+[0]*N
    for p in pn:
        for i in range(N,-1,-1):
            if p > 0 and i+p <= N:
                Q[i+p] = max(Q[i+p], Q[i]+1)
    return Q[N]-1

print(dpsum(N))
0