結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 348 ms
36,052 KB
testcase_01 AC 348 ms
36,052 KB
testcase_02 AC 349 ms
36,052 KB
testcase_03 AC 347 ms
36,052 KB
testcase_04 AC 345 ms
36,052 KB
testcase_05 AC 349 ms
36,052 KB
testcase_06 AC 348 ms
36,052 KB
testcase_07 AC 347 ms
36,052 KB
testcase_08 AC 348 ms
36,336 KB
testcase_09 AC 349 ms
36,336 KB
testcase_10 AC 359 ms
36,340 KB
testcase_11 WA -
testcase_12 AC 403 ms
36,336 KB
testcase_13 WA -
testcase_14 AC 403 ms
36,336 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (276 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
        | 0 -> a
        | _ -> loop (n - 1) b ((a + b) % m)
    loop n 0 1


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

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