結果

問題 No.526 フィボナッチ数列の第N項をMで割った余りを求める
ユーザー taktak
提出日時 2018-08-04 07:33:16
言語 F#
(F# 4.0)
結果
AC  
実行時間 431 ms / 2,000 ms
コード長 256 bytes
コンパイル時間 14,043 ms
コンパイル使用メモリ 187,084 KB
実行使用メモリ 36,364 KB
最終ジャッジ日時 2023-10-19 21:45:59
合計ジャッジ時間 21,717 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 350 ms
36,076 KB
testcase_01 AC 352 ms
36,064 KB
testcase_02 AC 351 ms
36,064 KB
testcase_03 AC 351 ms
36,064 KB
testcase_04 AC 352 ms
36,064 KB
testcase_05 AC 351 ms
36,064 KB
testcase_06 AC 350 ms
36,064 KB
testcase_07 AC 351 ms
36,064 KB
testcase_08 AC 351 ms
36,348 KB
testcase_09 AC 351 ms
36,360 KB
testcase_10 AC 369 ms
36,364 KB
testcase_11 AC 427 ms
36,360 KB
testcase_12 AC 430 ms
36,364 KB
testcase_13 AC 431 ms
36,360 KB
testcase_14 AC 428 ms
36,360 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (747 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

let fib n m =
    let rec loop n a b =
        match n with
        | 0L -> a
        | _  -> loop (n - 1L) b ((a + b) % m)
    loop n 0L 1L

let N,M =
    let t = stdin.ReadLine().Split() |> Array.map int64
    t.[0], t.[1]

fib (N - 1L) M |> printfn "%i"
0