题解 | #跳台阶扩展问题# | C++
跳台阶扩展问题
https://www.nowcoder.com/practice/953b74ca5c4d44bb91f39ac4ddea0fee
#include <iostream> using namespace std; class Solution{ public: int countWays(int n) { int prefix = 0; int ans = 0; for (int i = 1; i<=n; i++) { ans = prefix + 1; prefix += ans; } return ans; } }; int main() { int n; std::cin >> n; std::cout << Solution().countWays(n); } // 64 位输出请用 printf("%lld")