995!!!!!!!!!!!!!!!!!!!!!!!!(玄n关)

P1255 数楼梯

Yuexingfei_qwq @ 2024-07-14 20:00:57

60pts,WA后4个,球调!!

#include <bits/stdc++.h>

using namespace std;

int n;
long long f[60];

inline long long g(const int &x) {
    if (f[x] != 0) {
        return f[x];
    }
    if (x <= 1) {
        return 1;
    }
    f[x] = g(x - 1) + g(x - 2);
    return f[x];
}

int main() {
    scanf ("%d", &n);
    memset(f, 0, sizeof(f));
    printf ("%lld\n", g(n));
    return 0;
}

orz


by 黄海辰 @ 2024-07-14 20:46:29

数组小了


by AAAuc03 @ 2024-07-15 10:22:43

第一,数组小了,第二,要用记忆话,第三,不用高精过不了


by AAAuc03 @ 2024-07-15 10:23:57

求关


by Yuexingfei_qwq @ 2024-07-15 11:50:01

@AAAuc03 已关


|