結果

問題 No.458 異なる素数の和
ユーザー urutomurutom
提出日時 2017-04-17 16:39:11
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,338 ms / 2,000 ms
コード長 245 bytes
コンパイル時間 683 ms
コンパイル使用メモリ 11,260 KB
実行使用メモリ 15,612 KB
最終ジャッジ日時 2023-09-26 10:46:15
合計ジャッジ時間 45,377 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,308 ms
15,504 KB
testcase_01 AC 1,316 ms
15,508 KB
testcase_02 AC 1,307 ms
15,376 KB
testcase_03 AC 1,313 ms
15,276 KB
testcase_04 AC 1,314 ms
15,480 KB
testcase_05 AC 1,320 ms
15,284 KB
testcase_06 AC 1,307 ms
15,360 KB
testcase_07 AC 1,308 ms
15,272 KB
testcase_08 AC 1,330 ms
15,476 KB
testcase_09 AC 1,314 ms
15,420 KB
testcase_10 AC 1,317 ms
15,480 KB
testcase_11 AC 1,338 ms
15,360 KB
testcase_12 AC 1,308 ms
15,396 KB
testcase_13 AC 1,309 ms
15,308 KB
testcase_14 AC 1,320 ms
15,280 KB
testcase_15 AC 1,311 ms
15,516 KB
testcase_16 AC 1,312 ms
15,612 KB
testcase_17 AC 1,312 ms
15,476 KB
testcase_18 AC 1,305 ms
15,260 KB
testcase_19 AC 1,336 ms
15,340 KB
testcase_20 AC 1,334 ms
15,500 KB
testcase_21 AC 1,322 ms
15,516 KB
testcase_22 AC 1,331 ms
15,440 KB
testcase_23 AC 1,327 ms
15,276 KB
testcase_24 AC 1,314 ms
15,352 KB
testcase_25 AC 1,314 ms
15,336 KB
testcase_26 AC 1,305 ms
15,332 KB
testcase_27 AC 1,322 ms
15,264 KB
testcase_28 AC 1,315 ms
15,360 KB
testcase_29 AC 1,312 ms
15,472 KB
testcase_30 AC 1,307 ms
15,268 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require"prime"
N=20000
dp=Array.new(N+1)
dp[0]=0
temp=0
Prime.each(N/4){|p|
	(N-p).downto(0){|k|
		next unless dp[k]
		temp=k+p
		unless dp[temp]
			dp[temp]=dp[k]+1
		else
			dp[temp]=dp[k]+1 if dp[k]+1>dp[temp]
		end 
	}
}

p dp[gets.to_i]||-1
0