题解 | #N阶楼梯上楼问题#
N阶楼梯上楼问题
https://www.nowcoder.com/practice/c978e3375b404d598f1808e4f89ac551
#include <iostream> using namespace std; int main() { int N; cin >> N; int a = 1, b = 1, tmp; if (N != 1) { for (int i = 1; i < N; i++) { tmp = b; b = a + b; a = tmp; } } cout << b; } // 64 位输出请用 printf("%lld")
线性dp+状态压缩