結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー motimoti
提出日時 2018-05-20 08:46:29
言語 Perl
(5.38.2)
結果
AC  
実行時間 791 ms / 2,000 ms
コード長 217 bytes
コンパイル時間 43 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 5,132 KB
最終ジャッジ日時 2023-09-10 23:54:10
合計ジャッジ時間 4,221 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,820 KB
testcase_01 AC 5 ms
5,132 KB
testcase_02 AC 6 ms
4,928 KB
testcase_03 AC 5 ms
4,952 KB
testcase_04 AC 5 ms
4,968 KB
testcase_05 AC 5 ms
5,072 KB
testcase_06 AC 6 ms
5,088 KB
testcase_07 AC 5 ms
5,040 KB
testcase_08 AC 9 ms
4,924 KB
testcase_09 AC 20 ms
4,972 KB
testcase_10 AC 160 ms
5,072 KB
testcase_11 AC 769 ms
5,016 KB
testcase_12 AC 767 ms
4,932 KB
testcase_13 AC 773 ms
5,032 KB
testcase_14 AC 791 ms
4,868 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

use strict;
use warnings;

my ($n, $m) = split / /,<>;
chomp $m;
my ($f1, $f2) = (0, 1);
my $f3;
for (my $i = 2; $i < $n; $i++) {
  $f3 = ($f1 + $f2) % $m;
  ($f1, $f2) = ($f2, $f3);
}
print $f3;
0