結果

問題 No.314 ケンケンパ
ユーザー taktak
提出日時 2019-06-10 14:08:09
言語 F#
(F# 4.0)
結果
AC  
実行時間 58 ms / 1,000 ms
コード長 510 bytes
コンパイル時間 7,165 ms
コンパイル使用メモリ 190,644 KB
実行使用メモリ 29,312 KB
最終ジャッジ日時 2024-04-15 20:20:22
合計ジャッジ時間 8,188 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
29,312 KB
testcase_01 AC 50 ms
29,044 KB
testcase_02 AC 49 ms
29,056 KB
testcase_03 AC 49 ms
28,928 KB
testcase_04 AC 52 ms
28,928 KB
testcase_05 AC 50 ms
29,308 KB
testcase_06 AC 51 ms
29,056 KB
testcase_07 AC 49 ms
29,048 KB
testcase_08 AC 50 ms
29,312 KB
testcase_09 AC 49 ms
29,312 KB
testcase_10 AC 53 ms
28,920 KB
testcase_11 AC 51 ms
28,800 KB
testcase_12 AC 50 ms
28,928 KB
testcase_13 AC 50 ms
29,184 KB
testcase_14 AC 50 ms
29,056 KB
testcase_15 AC 52 ms
29,304 KB
testcase_16 AC 50 ms
29,312 KB
testcase_17 AC 51 ms
29,312 KB
testcase_18 AC 55 ms
29,312 KB
testcase_19 AC 56 ms
29,304 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (234 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
*)

[<Struct>]
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