結果

問題 No.458 異なる素数の和
ユーザー cielciel
提出日時 2016-12-09 01:20:13
言語 Ruby
(3.3.0)
結果
AC  
実行時間 462 ms / 2,000 ms
コード長 134 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 11,568 KB
実行使用メモリ 15,596 KB
最終ジャッジ日時 2023-09-18 14:57:12
合計ジャッジ時間 7,041 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
15,308 KB
testcase_01 AC 290 ms
15,428 KB
testcase_02 AC 320 ms
15,500 KB
testcase_03 AC 179 ms
15,500 KB
testcase_04 AC 190 ms
15,308 KB
testcase_05 AC 428 ms
15,580 KB
testcase_06 AC 307 ms
15,532 KB
testcase_07 AC 102 ms
15,288 KB
testcase_08 AC 429 ms
15,464 KB
testcase_09 AC 131 ms
15,264 KB
testcase_10 AC 93 ms
15,400 KB
testcase_11 AC 462 ms
15,596 KB
testcase_12 AC 94 ms
15,208 KB
testcase_13 AC 95 ms
15,336 KB
testcase_14 AC 94 ms
15,528 KB
testcase_15 AC 95 ms
15,256 KB
testcase_16 AC 153 ms
15,272 KB
testcase_17 AC 93 ms
15,324 KB
testcase_18 AC 95 ms
15,132 KB
testcase_19 AC 96 ms
15,340 KB
testcase_20 AC 91 ms
15,208 KB
testcase_21 AC 94 ms
15,376 KB
testcase_22 AC 93 ms
15,264 KB
testcase_23 AC 93 ms
15,132 KB
testcase_24 AC 92 ms
15,212 KB
testcase_25 AC 93 ms
15,224 KB
testcase_26 AC 94 ms
15,344 KB
testcase_27 AC 307 ms
15,584 KB
testcase_28 AC 459 ms
15,416 KB
testcase_29 AC 122 ms
15,212 KB
testcase_30 AC 255 ms
15,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require'prime'
a=[0]*(1+n=gets.to_i)
a[0]=1
Prime.each([n,999].min){|e|
	n.downto(e){|i|a[i-e]>0&&a[i]=[a[i-e]+1,a[i]].max}
}
p a[n]-1
0