【小米oj】 爬楼梯

斐波那契数列 f[0]=1,f[1]=1,f[n]=f[n-1]+f[n-2](x>=2)

 1 #define mm(a) memset(a,0,sizeof(a));
 2 #define max(x,y) (x)>(y)?(x):(y)
 3 #define min(x,y) (x)<(y)?(x):(y)
 4 #define Fopen freopen("1.in","r",stdin); freopen("m.out","w",stdout);
 5 #define rep(i,a,b) for(ll i=(a);i<=(b);i++)
 6 #define per(i,b,a) for(ll i=(b);i>=(a);i--)
 7 #include<bits/stdc++.h>
 8 typedef long long ll;
 9 #define PII pair<ll,ll>
10 using namespace std;
11 const int INF=0x3f3f3f3f;
12 const int MAXN=(int)2e6+5;
13 
14 ll dp[MAXN];
15 int main()
16 {
17     int n;
18     dp[1]=1;
19     dp[0]=1;
20     scanf("%d",&n);
21     for(int i=2;i<=n;i++)dp[i]=dp[i-1]+dp[i-2];
22     printf("%lld
",dp[n]);
23 
24     return 0;
25 }
原文地址:https://www.cnblogs.com/dogenya/p/10815664.html