結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー 37zigen37zigen
提出日時 2018-04-21 07:54:03
言語 Fortran
(gFortran 13.2.0)
結果
TLE  
実行時間 -
コード長 451 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 26,140 KB
実行使用メモリ 80,700 KB
最終ジャッジ日時 2023-09-09 12:17:26
合計ジャッジ時間 6,690 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
80,632 KB
testcase_01 AC 27 ms
80,664 KB
testcase_02 AC 39 ms
80,588 KB
testcase_03 AC 26 ms
80,684 KB
testcase_04 AC 61 ms
80,692 KB
testcase_05 TLE -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

module mdl
    integer*8::f(10000000)
contains
    recursive function fib(n,m)result(res)
        integer*8::n,m,res
        if(f(n)/=-1)then
            res=f(n)
        else
            res=mod(fib(n-1,m)+fib(n-2,m),m)
        end if
    end function
end module


program main
    use mdl
    implicit none
    integer*8::i,j,k,n,m
    f(1)=0
    f(2)=1
    do i=3,size(f)
        f(i)=-1
    end do
    read(*,*)n,m
    print*,fib(n,m)
end program
0