結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
15,136 KB
testcase_01 AC 251 ms
15,396 KB
testcase_02 AC 275 ms
15,440 KB
testcase_03 AC 165 ms
15,540 KB
testcase_04 AC 171 ms
15,424 KB
testcase_05 AC 368 ms
15,408 KB
testcase_06 AC 267 ms
15,424 KB
testcase_07 AC 99 ms
15,344 KB
testcase_08 AC 368 ms
15,396 KB
testcase_09 AC 127 ms
15,232 KB
testcase_10 AC 95 ms
15,364 KB
testcase_11 AC 396 ms
15,568 KB
testcase_12 AC 96 ms
15,332 KB
testcase_13 AC 94 ms
15,448 KB
testcase_14 AC 93 ms
15,136 KB
testcase_15 AC 94 ms
15,500 KB
testcase_16 AC 141 ms
15,232 KB
testcase_17 AC 94 ms
15,360 KB
testcase_18 AC 94 ms
15,144 KB
testcase_19 AC 97 ms
15,132 KB
testcase_20 AC 96 ms
15,268 KB
testcase_21 AC 95 ms
15,420 KB
testcase_22 AC 95 ms
15,332 KB
testcase_23 AC 95 ms
15,176 KB
testcase_24 AC 95 ms
15,368 KB
testcase_25 AC 95 ms
15,172 KB
testcase_26 AC 97 ms
15,236 KB
testcase_27 AC 270 ms
15,396 KB
testcase_28 AC 391 ms
15,292 KB
testcase_29 AC 118 ms
15,172 KB
testcase_30 AC 229 ms
15,528 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

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