結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー くれちーくれちー
提出日時 2017-04-04 11:21:33
言語 Perl
(5.38.2)
結果
AC  
実行時間 697 ms / 2,000 ms
コード長 183 bytes
コンパイル時間 552 ms
コンパイル使用メモリ 5,216 KB
実行使用メモリ 4,752 KB
最終ジャッジ日時 2023-09-22 17:10:34
合計ジャッジ時間 3,879 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,476 KB
testcase_01 AC 2 ms
4,480 KB
testcase_02 AC 3 ms
4,660 KB
testcase_03 AC 3 ms
4,724 KB
testcase_04 AC 3 ms
4,664 KB
testcase_05 AC 2 ms
4,500 KB
testcase_06 AC 3 ms
4,600 KB
testcase_07 AC 3 ms
4,744 KB
testcase_08 AC 4 ms
4,752 KB
testcase_09 AC 16 ms
4,476 KB
testcase_10 AC 141 ms
4,500 KB
testcase_11 AC 691 ms
4,472 KB
testcase_12 AC 692 ms
4,724 KB
testcase_13 AC 697 ms
4,556 KB
testcase_14 AC 693 ms
4,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

my ($n, $m) = split /\s/, <>;
my ($fib1, $fib2, $fib) = (0, 1, 1);
for (my $i = 3; $i < $n; $i++) {
    $fib1 = $fib2;
    $fib2 = $fib;
    $fib = ($fib1 + $fib2) % $m;
}
print $fib;
0