結果

問題 No.458 異なる素数の和
ユーザー pluto77pluto77
提出日時 2016-12-19 13:43:09
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 387 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 77,620 KB
実行使用メモリ 80,200 KB
最終ジャッジ日時 2023-09-18 15:08:02
合計ジャッジ時間 6,500 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
78,748 KB
testcase_01 AC 184 ms
79,996 KB
testcase_02 AC 170 ms
79,816 KB
testcase_03 AC 109 ms
79,912 KB
testcase_04 AC 115 ms
80,116 KB
testcase_05 AC 251 ms
80,168 KB
testcase_06 AC 165 ms
80,136 KB
testcase_07 AC 87 ms
79,084 KB
testcase_08 AC 251 ms
79,924 KB
testcase_09 AC 100 ms
79,852 KB
testcase_10 AC 78 ms
76,464 KB
testcase_11 AC 281 ms
80,132 KB
testcase_12 AC 76 ms
76,952 KB
testcase_13 AC 78 ms
76,348 KB
testcase_14 AC 76 ms
76,804 KB
testcase_15 AC 78 ms
76,320 KB
testcase_16 AC 102 ms
79,916 KB
testcase_17 AC 77 ms
76,648 KB
testcase_18 AC 77 ms
76,980 KB
testcase_19 AC 78 ms
76,804 KB
testcase_20 AC 78 ms
77,900 KB
testcase_21 AC 78 ms
76,564 KB
testcase_22 AC 77 ms
76,844 KB
testcase_23 AC 79 ms
77,640 KB
testcase_24 AC 77 ms
77,756 KB
testcase_25 AC 76 ms
76,816 KB
testcase_26 AC 77 ms
76,812 KB
testcase_27 AC 160 ms
79,916 KB
testcase_28 AC 278 ms
80,200 KB
testcase_29 AC 94 ms
79,988 KB
testcase_30 AC 139 ms
79,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki458

def isPrime(n):
 if n==2 or n==3: return True
 if n%2==0 or n<2: return False
 for i in range(3,int(n**0.5)+1,2):
  if n%i==0:
   return False    
 return True

n=int(raw_input())

dp=[-3 for i in xrange(n+1)]
dp[0]=0
for i in xrange(2,n+1):
 if isPrime(i)==True:
  for j in xrange(n-i,-1,-1):
   dp[i+j]=max(dp[i+j],dp[j]+1)
#print dp
if dp[n]>0:
 print dp[n]
else:
 print -1
0