Files
python/GESP/Mkx/20250322T2.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

26 lines
624 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 11000;
// 是path的集合每个path表示一种上台阶的方法
string paths[N]; // 字符串数组,每一个元素都是字符串
int pl;
void dfs(int u, string path) { // 有 n 阶要爬
if (u == 0) {
paths[pl++] = path; // 爬完了
return;
}
dfs(u - 1, path + "1"); // 我上了一阶,还有 n-1 阶
dfs(u - 2, path + "2"); // 我上了 2 阶,还有 n-1 阶
}
int main() {
int n;
cin >> n;
dfs(n, "");
cout << pl << endl;
for (int i = 0; i < pl; i++)
cout << paths[i] << endl;
return 0;
}