結果

問題 No.481 1から10
ユーザー sironekotorosironekotoro
提出日時 2018-12-09 15:52:30
言語 Perl
(5.38.2)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 5,156 KB
実行使用メモリ 4,780 KB
最終ジャッジ日時 2023-10-14 14:23:21
合計ジャッジ時間 911 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,780 KB
testcase_01 AC 3 ms
4,672 KB
testcase_02 AC 3 ms
4,740 KB
testcase_03 AC 2 ms
4,676 KB
testcase_04 AC 3 ms
4,684 KB
testcase_05 AC 3 ms
4,724 KB
testcase_06 AC 3 ms
4,664 KB
testcase_07 AC 3 ms
4,732 KB
testcase_08 AC 3 ms
4,684 KB
testcase_09 AC 2 ms
4,780 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

use v5.16;

my $input = <>;
# my $input = "1 2 4 5 6 7 8 9 10";
chomp $input;

# 比較用のハッシュを作成する
# keyは数字、valueは0
# (1 => 0, 2 => 0, 3 => 0, ...)
my %h = map { $_ => 0 } ( 1 .. 10 );

# 入力された数字を分割、ハッシュのkeyに
# 該当するものはvalueをインクリメントする
for my $n ( split / /, $input ) {
    $h{$n}++;
}

# ハッシュのvalueが0のものが抜け落ちた数字
say grep { $h{$_} == 0 } keys %h;

0