結果

問題 No.458 異なる素数の和
ユーザー hogeover30hogeover30
提出日時 2016-12-28 14:05:10
言語 Ruby
(3.3.0)
結果
AC  
実行時間 376 ms / 2,000 ms
コード長 151 bytes
コンパイル時間 46 ms
コンパイル使用メモリ 11,424 KB
実行使用メモリ 15,572 KB
最終ジャッジ日時 2023-09-18 15:14:32
合計ジャッジ時間 6,460 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
15,132 KB
testcase_01 AC 240 ms
15,572 KB
testcase_02 AC 261 ms
15,572 KB
testcase_03 AC 159 ms
15,116 KB
testcase_04 AC 171 ms
15,324 KB
testcase_05 AC 355 ms
15,520 KB
testcase_06 AC 260 ms
15,528 KB
testcase_07 AC 99 ms
15,412 KB
testcase_08 AC 350 ms
15,380 KB
testcase_09 AC 126 ms
15,288 KB
testcase_10 AC 94 ms
15,348 KB
testcase_11 AC 376 ms
15,332 KB
testcase_12 AC 97 ms
15,184 KB
testcase_13 AC 97 ms
15,364 KB
testcase_14 AC 96 ms
15,380 KB
testcase_15 AC 95 ms
15,368 KB
testcase_16 AC 139 ms
15,132 KB
testcase_17 AC 96 ms
15,188 KB
testcase_18 AC 96 ms
15,096 KB
testcase_19 AC 95 ms
15,308 KB
testcase_20 AC 95 ms
15,304 KB
testcase_21 AC 98 ms
15,200 KB
testcase_22 AC 97 ms
15,316 KB
testcase_23 AC 95 ms
15,360 KB
testcase_24 AC 98 ms
15,368 KB
testcase_25 AC 97 ms
15,312 KB
testcase_26 AC 96 ms
15,348 KB
testcase_27 AC 254 ms
15,572 KB
testcase_28 AC 372 ms
15,396 KB
testcase_29 AC 118 ms
15,316 KB
testcase_30 AC 220 ms
15,496 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require'prime'
n=gets.to_i
dp=[-1]*-~n
dp[0]=0
Prime.each(999){|p|
	(n-p).downto(0){|i|
		dp[i+p]=dp[i]+1 if dp[i]>=0 and dp[i+p]<dp[i]+1
	}
}
p dp[n]
0