結果

問題 No.458 異なる素数の和
ユーザー tookunn_1213tookunn_1213
提出日時 2017-03-28 21:43:07
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 385 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 77,024 KB
最終ジャッジ日時 2023-09-20 18:35:46
合計ジャッジ時間 7,512 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 78 ms
71,252 KB
testcase_11 WA -
testcase_12 AC 77 ms
71,316 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 77 ms
71,048 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
prime = []
for i in range(2,N+1):
	j = 2
	flag = False
	while j * j <= i:
		if i % j == 0:
			flag = True
			break
		j+=1
	if not flag:
		prime.append(i)
P = len(prime)
dp = [0 for i in range(N+1)]
dp[0] = 1
for i in range(P):
	for j in range(N,-1,-1):
		if dp[j] and j+prime[i] <= N:
			dp[j+prime[i]] = max(dp[j+prime[i]],dp[j]+1)
print(dp[N] if dp[N] != 0 else -1)
0