結果

問題 No.314 ケンケンパ
ユーザー taktak
提出日時 2019-06-10 14:01:03
言語 F#
(F# 4.0)
結果
AC  
実行時間 81 ms / 1,000 ms
コード長 498 bytes
コンパイル時間 6,757 ms
コンパイル使用メモリ 190,700 KB
実行使用メモリ 52,864 KB
最終ジャッジ日時 2024-04-15 20:20:11
合計ジャッジ時間 8,690 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
52,864 KB
testcase_01 AC 50 ms
29,056 KB
testcase_02 AC 50 ms
29,056 KB
testcase_03 AC 50 ms
29,184 KB
testcase_04 AC 48 ms
29,184 KB
testcase_05 AC 49 ms
29,056 KB
testcase_06 AC 50 ms
28,672 KB
testcase_07 AC 48 ms
28,928 KB
testcase_08 AC 48 ms
29,056 KB
testcase_09 AC 50 ms
29,164 KB
testcase_10 AC 49 ms
29,164 KB
testcase_11 AC 48 ms
29,164 KB
testcase_12 AC 49 ms
28,928 KB
testcase_13 AC 50 ms
28,800 KB
testcase_14 AC 49 ms
29,184 KB
testcase_15 AC 49 ms
29,568 KB
testcase_16 AC 50 ms
30,336 KB
testcase_17 AC 57 ms
32,640 KB
testcase_18 AC 69 ms
44,672 KB
testcase_19 AC 81 ms
52,736 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (214 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

module Yuki

open System

let MOD = (int 1e9) + 7

(*
    Ken_1 -> A
    Ken_2 -> B
    Pa    -> C
*)
type State =
    { A : int
      B : int
      C : int }
    member __.Sum =
        ((__.A + __.B) % MOD + __.C) % MOD

let solve n =
    let rec f state =
        function
        | 0 -> state
        | n -> f { A = state.C; B = state.A; C = (state.A + state.B) % MOD } (n - 1)
    (f { A = 1; B = 0; C = 0 } (n - 1)).Sum

    
let N = Console.ReadLine() |> int

N
|> solve
|> Console.WriteLine
0