結果

問題 No.458 異なる素数の和
ユーザー ntudantuda
提出日時 2024-01-02 17:38:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 579 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 187,264 KB
最終ジャッジ日時 2024-01-02 17:39:06
合計ジャッジ時間 7,177 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
59,976 KB
testcase_01 AC 249 ms
77,028 KB
testcase_02 AC 311 ms
77,772 KB
testcase_03 AC 97 ms
75,716 KB
testcase_04 AC 112 ms
75,844 KB
testcase_05 AC 693 ms
173,920 KB
testcase_06 AC 294 ms
77,644 KB
testcase_07 AC 46 ms
64,304 KB
testcase_08 WA -
testcase_09 AC 65 ms
75,588 KB
testcase_10 RE -
testcase_11 AC 821 ms
187,264 KB
testcase_12 AC 35 ms
53,716 KB
testcase_13 AC 33 ms
53,716 KB
testcase_14 AC 33 ms
53,716 KB
testcase_15 AC 33 ms
53,716 KB
testcase_16 AC 75 ms
75,716 KB
testcase_17 AC 34 ms
53,716 KB
testcase_18 AC 35 ms
53,716 KB
testcase_19 AC 34 ms
53,716 KB
testcase_20 AC 36 ms
53,716 KB
testcase_21 AC 37 ms
53,716 KB
testcase_22 AC 35 ms
53,716 KB
testcase_23 AC 36 ms
53,716 KB
testcase_24 AC 35 ms
53,716 KB
testcase_25 AC 37 ms
53,716 KB
testcase_26 AC 36 ms
53,716 KB
testcase_27 AC 268 ms
77,660 KB
testcase_28 AC 780 ms
181,116 KB
testcase_29 AC 58 ms
72,644 KB
testcase_30 AC 184 ms
76,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def seachPrimeNum(N):
    max = int(N ** 0.5)
    seachList = [i for i in range(2, N + 1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum


N = int(input())
PL = seachPrimeNum(N)
X = [0] * (N + 1)
Q = {0}
for p in PL:
    for q in sorted(list(Q)):
        if p + q > N:
            break
        X[p + q] = max(X[p + q], X[q] + 1)
        Q.add(p + q)

if X[N] > 0:
    print(X[N])
else:
    print(-1)
0