結果

問題 No.458 異なる素数の和
ユーザー tailstails
提出日時 2016-12-09 00:41:41
言語 Perl
(5.38.2)
結果
AC  
実行時間 586 ms / 2,000 ms
コード長 174 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 6,028 KB
最終ジャッジ日時 2023-09-18 14:54:09
合計ジャッジ時間 6,842 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
4,588 KB
testcase_01 AC 334 ms
5,244 KB
testcase_02 AC 377 ms
5,428 KB
testcase_03 AC 170 ms
4,796 KB
testcase_04 AC 186 ms
4,916 KB
testcase_05 AC 539 ms
5,912 KB
testcase_06 AC 364 ms
5,412 KB
testcase_07 AC 52 ms
4,652 KB
testcase_08 AC 540 ms
5,848 KB
testcase_09 AC 104 ms
4,720 KB
testcase_10 AC 44 ms
4,704 KB
testcase_11 AC 586 ms
5,996 KB
testcase_12 AC 44 ms
4,604 KB
testcase_13 AC 43 ms
4,604 KB
testcase_14 AC 43 ms
4,580 KB
testcase_15 AC 43 ms
4,612 KB
testcase_16 AC 133 ms
4,792 KB
testcase_17 AC 43 ms
4,624 KB
testcase_18 AC 43 ms
4,712 KB
testcase_19 AC 43 ms
4,652 KB
testcase_20 AC 44 ms
4,648 KB
testcase_21 AC 44 ms
4,604 KB
testcase_22 AC 44 ms
4,608 KB
testcase_23 AC 43 ms
4,512 KB
testcase_24 AC 44 ms
4,588 KB
testcase_25 AC 44 ms
4,588 KB
testcase_26 AC 43 ms
4,592 KB
testcase_27 AC 362 ms
5,372 KB
testcase_28 AC 580 ms
6,028 KB
testcase_29 AC 80 ms
4,676 KB
testcase_30 AC 286 ms
5,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

$n=<>;
$h[0]=0;
for$m(grep{!grep{$i%$_<1}2..($i=$_)-1}2..999){
	for$i(reverse $m..$n){
		$h[$i]=$h[$i-$m]+1 if defined $h[$i-$m] && $h[$i]<$h[$i-$m]+1;
	}
}
print $h[$n]||-1;
0