2 条题解
-
4
#include using namespace std; int countWays(int n) { if (n <= 0) { return 0; } else if (n == 1) { return 1; } else if (n == 2) { return 2; } else { return countWays(n - 1) + countWays(n - 2); } } int main() { int n; while (cin >> n) { cout << countWays(n) << endl; } return 0; }
信息
- ID
- 105
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- (无)
- 递交数
- 165
- 已通过
- 39
- 上传者