結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,948 KB
testcase_01 AC 5 ms
5,024 KB
testcase_02 AC 5 ms
4,904 KB
testcase_03 AC 5 ms
5,032 KB
testcase_04 AC 5 ms
5,072 KB
testcase_05 AC 5 ms
4,908 KB
testcase_06 AC 4 ms
5,060 KB
testcase_07 AC 5 ms
5,016 KB
testcase_08 AC 7 ms
5,040 KB
testcase_09 AC 19 ms
5,044 KB
testcase_10 AC 145 ms
5,032 KB
testcase_11 AC 701 ms
4,848 KB
testcase_12 AC 696 ms
4,908 KB
testcase_13 AC 694 ms
5,064 KB
testcase_14 AC 698 ms
4,952 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