.........

P1255 数楼梯

zyy0619 @ 2024-11-17 16:20:21

#include <bits/stdc++.h>
using namespace std;
int a[5005][5005];

int main() {
    int b, n;
    cin >> n;
    a[1][1] = 1;
    a[2][1] = 2;
    for (int i = 3; i <= n; i++) {
        for (int j = 1; j <= b; j++ ) {
            a[i][j] += a[i - 1][j] + a [i - 2][j];
            a[i][j + 1] = a[i][j] / 10;
            a[i][j] %= 10;
        }
        if (a[i][b + 1] > 0) {
            b++;
        }
    }
    for (int i = b; i >= 1; i--) {
        cout << a[n][i];
    }
    return 0;
}

by cpp12312 @ 2024-11-21 21:40:12

b没付至


|