题解 | 跳台阶扩展问题
跳台阶扩展问题
https://www.nowcoder.com/practice/953b74ca5c4d44bb91f39ac4ddea0fee
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0);
typedef long long LL;
//const int N=;
int main()
{
IOS
int n;
cin>>n;
cout<<(1<<n-1);
return 0;
}
递推可以得知f(n)=f(n-1)+f(n-2)+f(n-3)+…+f(1), f(n-1)=f(n-2)+f(n-3)+f(n-4)+…+f(1)
f(n)=2*f(n-1)
f(0)=1
得到公式f(n)=2^(n-1)输出即可,公式解
美的集团公司福利 720人发布