题解 | #跳台阶扩展问题#
跳台阶扩展问题
https://www.nowcoder.com/practice/953b74ca5c4d44bb91f39ac4ddea0fee
其实是个数学问题
//思路: //f(n) = f(n-1) + ... + f(1) + 1 //f(1) = 1 //1 2 3 4 5 //1f1 1f1+1 2f1+2 4f1+4 8f1+8 //1 2 4 8 16 #include<iostream> #include<cmath> using namespace std; int main(){ int n; cin >> n; cout << pow(2, n-1); return 0; }