mirror of
https://github.com/krahets/hello-algo.git
synced 2026-03-12 17:51:33 +08:00
* docs: add Japanese documents (`ja/docs`) * docs: add Japanese documents (`ja/codes`) * docs: add Japanese documents * Remove pythontutor blocks in ja/ * Add an empty at the end of each markdown file. * Add the missing figures (use the English version temporarily). * Add index.md for Japanese version. * Add index.html for Japanese version. * Add missing index.assets * Fix backtracking_algorithm.md for Japanese version. * Add avatar_eltociear.jpg. Fix image links on the Japanese landing page. * Add the Japanese banner. --------- Co-authored-by: krahets <krahets@163.com>
32 lines
625 B
C++
32 lines
625 B
C++
/**
|
|
* File: climbing_stairs_dfs.cpp
|
|
* Created Time: 2023-06-30
|
|
* Author: krahets (krahets@163.com)
|
|
*/
|
|
|
|
#include "../utils/common.hpp"
|
|
|
|
/* 探索 */
|
|
int dfs(int i) {
|
|
// 既知の dp[1] と dp[2] を返す
|
|
if (i == 1 || i == 2)
|
|
return i;
|
|
// dp[i] = dp[i-1] + dp[i-2]
|
|
int count = dfs(i - 1) + dfs(i - 2);
|
|
return count;
|
|
}
|
|
|
|
/* 階段登り:探索 */
|
|
int climbingStairsDFS(int n) {
|
|
return dfs(n);
|
|
}
|
|
|
|
/* ドライバーコード */
|
|
int main() {
|
|
int n = 9;
|
|
|
|
int res = climbingStairsDFS(n);
|
|
cout << n << "段の階段を登る解は" << res << "通りです" << endl;
|
|
|
|
return 0;
|
|
} |