結果

問題 No.458 異なる素数の和
ユーザー urutomurutom
提出日時 2017-04-17 15:59:24
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 211 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 15,656 KB
最終ジャッジ日時 2023-09-26 10:40:54
合計ジャッジ時間 17,177 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
15,236 KB
testcase_01 AC 710 ms
15,360 KB
testcase_02 WA -
testcase_03 AC 226 ms
15,344 KB
testcase_04 AC 268 ms
15,380 KB
testcase_05 AC 1,935 ms
15,464 KB
testcase_06 AC 860 ms
15,364 KB
testcase_07 AC 97 ms
15,236 KB
testcase_08 AC 1,959 ms
15,572 KB
testcase_09 AC 132 ms
15,344 KB
testcase_10 AC 92 ms
15,140 KB
testcase_11 TLE -
testcase_12 AC 93 ms
15,080 KB
testcase_13 AC 93 ms
15,140 KB
testcase_14 AC 92 ms
15,084 KB
testcase_15 AC 93 ms
15,160 KB
testcase_16 AC 169 ms
15,296 KB
testcase_17 AC 95 ms
15,312 KB
testcase_18 AC 94 ms
15,316 KB
testcase_19 AC 92 ms
15,340 KB
testcase_20 AC 92 ms
15,212 KB
testcase_21 AC 93 ms
15,412 KB
testcase_22 AC 95 ms
15,344 KB
testcase_23 AC 95 ms
15,204 KB
testcase_24 AC 91 ms
15,236 KB
testcase_25 AC 92 ms
15,332 KB
testcase_26 AC 93 ms
15,348 KB
testcase_27 WA -
testcase_28 TLE -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require"prime"
n=gets.to_i
dp=Array.new(n+1)
dp[0]=0
max=temp=0
Prime.each(n){|p|
	0.upto(max){|k|
		next unless dp[k]
		temp=k+p
		break if temp>n+1
		dp[temp]=dp[k]+1 unless dp[temp]
	}
	max=temp
}
p dp[n]||-1
0