結果

問題 No.458 異なる素数の和
コンテスト
ユーザー こる
提出日時 2017-01-06 21:28:44
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
RE  
実行時間 -
コード長 457 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 327 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 21,596 KB
最終ジャッジ日時 2026-05-26 18:59:36
合計ジャッジ時間 6,763 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 1 RE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
n=int(input())
a=list(range(n+1))
a[1]=0
i=2
while i**2<=n:
    j=i+i
    while j<=n:
        a[j]=0
        j+=i
    i+=1
list=[]
for i in a:
    if i!=0:
        list.append(i)
def fun(sum,index,target,count):
    if sum==target:
        print(count)
        sys.exit()
        return
    if index==len(list) or sum>target:
        return
    fun(sum+list[index],index+1,target,count+1)
    fun(sum,index+1,target,count)

fun(0,0,n,0)
print(-1)
0