結果

問題 No.786 京都大学の過去問
ユーザー maimai
提出日時 2019-02-08 21:47:48
言語 Ruby
(3.3.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 219 bytes
コンパイル時間 168 ms
コンパイル使用メモリ 11,380 KB
実行使用メモリ 15,288 KB
最終ジャッジ日時 2023-09-11 04:16:03
合計ジャッジ時間 1,288 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,172 KB
testcase_01 AC 83 ms
15,288 KB
testcase_02 AC 81 ms
15,268 KB
testcase_03 AC 87 ms
15,176 KB
testcase_04 AC 82 ms
15,172 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i); end

@memo = {}
def dfs(n,last = nil)
    return 1 if n == 0
    return 0 if n < 0
    return @memo[n] if @memo[n]
    return @memo[n] = dfs(n-2, 2) + dfs(n-1, 1)
end

p dfs(gets.to_i)
0