50分求助QAQ

P1255 数楼梯

CaiGuan @ 2023-07-31 08:08:35

#include<bits/stdc++.h>
using namespace std;
int a[100001];
int n;
int fa(int k){
    for(int i=3;i<=k;i++){
        a[i]=a[i-1]+a[i-2];
    }
    return a[k];
}
int main(){
    cin>>n; 
    a[1]=1;a[2]=2;
    cout<<fa(n);
}

by Ferdina_zcjb @ 2023-07-31 08:15:59

@CaiGuan

高精度被你吃了?


by Zack11 @ 2023-07-31 08:19:04

“对于100% 的数据,1≤N≤5000“ 斐波那契数列第5000项,数据太大,必须用高精度


by Lxz120605 @ 2023-07-31 09:23:39

高精度:你干嘛


by xushuxin @ 2023-10-14 19:09:10

我也50!

#include <bits/stdc++.h>
using namespace std;
long  long  n,ans=0;
void dfs(int x){
    if(x<n){
        dfs(x+1);
        dfs(x+2);
    }
    if(x==n)ans++;
} 
int main(){
    cin>>n;
    dfs(0); 
    cout<<ans;
    return 0;
}

by xushuxin @ 2023-10-14 19:10:29

如何高精


|