結果

問題 No.458 異なる素数の和
ユーザー aqua_tenhouaqua_tenhou
提出日時 2020-09-15 21:45:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 613 ms / 2,000 ms
コード長 602 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 78,092 KB
最終ジャッジ日時 2023-09-04 02:57:47
合計ジャッジ時間 8,661 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
76,396 KB
testcase_01 AC 265 ms
77,656 KB
testcase_02 AC 310 ms
77,348 KB
testcase_03 AC 147 ms
77,736 KB
testcase_04 AC 157 ms
77,788 KB
testcase_05 AC 534 ms
77,772 KB
testcase_06 AC 300 ms
77,648 KB
testcase_07 AC 92 ms
76,820 KB
testcase_08 AC 536 ms
77,808 KB
testcase_09 AC 118 ms
77,640 KB
testcase_10 AC 71 ms
71,264 KB
testcase_11 AC 613 ms
77,876 KB
testcase_12 AC 71 ms
71,624 KB
testcase_13 AC 71 ms
71,468 KB
testcase_14 AC 71 ms
71,468 KB
testcase_15 AC 70 ms
71,580 KB
testcase_16 AC 131 ms
77,288 KB
testcase_17 AC 75 ms
76,116 KB
testcase_18 AC 76 ms
75,984 KB
testcase_19 AC 73 ms
71,276 KB
testcase_20 AC 78 ms
76,076 KB
testcase_21 AC 71 ms
71,452 KB
testcase_22 AC 71 ms
71,696 KB
testcase_23 AC 76 ms
75,996 KB
testcase_24 AC 77 ms
76,076 KB
testcase_25 AC 72 ms
71,564 KB
testcase_26 AC 75 ms
75,768 KB
testcase_27 AC 294 ms
77,636 KB
testcase_28 AC 605 ms
78,092 KB
testcase_29 AC 108 ms
76,944 KB
testcase_30 AC 224 ms
77,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def fact(A):
    c0 = A
    r = 2
    lis = []
    count = 1
    while A != 1:
        if A%r == 0:
            A = A//r
            lis.append(r)
            r = 2
        else:
            r += 1
        if r > int(pow(c0,0.5))+1:
            lis.append(A)
            break
    return(lis)

L = []
n = int(input())
for i in range(2,n+1):
    s = fact(i)
    if len(s) == 1:
        L.append(i)
d = [-1]*(n+1)
d[0] = 0
for x in L:

    for i in range(n+1):
        j = n - i
        if x+j > n:
            pass
        
        elif d[j] != -1:
            d[j+x] = max(d[j+x], d[j]+1)

print(d[-1])
0