60分求救

P1255 数楼梯

Zhongli_havingOrder @ 2024-11-24 13:47:42

#include <bits/stdc++.h>
using namespace std;
long long f(int n) {
    if (n == 0 || n == 1) {
        return 1;
    }
    long long prev2 = 1, prev1 = 1, current;
    for (int i = 2; i <= n; ++i) {
        current = prev1 + prev2;
        prev2 = prev1;
        prev1 = current;
    }
    return current;
}

int main() {
    int n;
    cin >> n;
    cout << f(n) << endl;
    return 0;
}

从第七个样例过不去


by xiaogu_ @ 2024-11-24 13:50:30

1≤N≤5000

要高精度


by Zhongli_havingOrder @ 2024-11-24 14:17:33

@xiaogu_ 淦,没看见


by Moxing_Terry @ 2024-12-01 09:48:44

...我也眼瞎了


by dundun0508 @ 2024-12-05 19:58:06

没事,我跟你一样


by Zhongli_havingOrder @ 2024-12-06 20:15:07

@Moxing_Terry你还有瞎的时候


by Moxing_Terry @ 2024-12-06 22:29:27

@Zhongli_havingOrder……


|