結果
問題 |
No.458 異なる素数の和
|
ユーザー |
![]() |
提出日時 | 2017-01-06 21:28:44 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 457 bytes |
コンパイル時間 | 141 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,904 KB |
最終ジャッジ日時 | 2024-12-17 14:47:44 |
合計ジャッジ時間 | 2,520 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 1 RE * 9 |
ソースコード
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)