大佬求助第一个案例输出一样 就是不过

P1464 Function

xiaopang666 @ 2024-08-24 16:27:58

#include<iostream>
using namespace std;
long long vectors[25][25][25] = {0};
#include<vector>
class zu
{
public:
    long long a, b, c, n=0;
};
long long vo(long long a, long long b, long long c)
{
    if (a <= 0 || b <= 0 || c <= 0)return 1;
    if (a > 20 || b > 20 || c > 20)return vo(20, 20, 20);
    if(a<b&&b<c)
    {
        if (vectors[a][b][c - 1] == 0)
            vectors[a][b][c - 1] = vo(a, b, c - 1);
        if (vectors[a][b - 1][c - 1] == 0)
            vectors[a][b - 1][c - 1] = vo(a, b - 1, c - 1);
        if (vectors[a][b-1][c ] == 0)
            vectors[a][b-1][c ] = vo(a, b-1, c);
        vectors[a][b][c] = vectors[a][b][c - 1] + vectors[a][b - 1][c - 1] - vectors[a][b - 1][c];

    }
    else

        {
            if (vectors[a - 1][b][c] == 0)
                vectors[a - 1][b][c] = vo(a - 1, b, c);
            if (vectors[a - 1][b - 1][c] == 0)
                vectors[a - 1][b - 1][c] = vo(a - 1, b - 1, c);
            if (vectors[a - 1][b ][c - 1] == 0)
                vectors[a - 1][b ][c - 1] = vo(a - 1, b , c - 1);
            if (vectors[a - 1][b - 1][c - 1] == 0)
                vectors[a - 1][b - 1][c - 1] = vo(a - 1, b - 1, c - 1);
            vectors[a][b][c] = vectors[a - 1][b][c] + vectors[a - 1][b - 1][c] + vectors[a - 1][b][c - 1] - vectors[a - 1][b - 1][c - 1];

        }
    return vectors[a][b][c];
    }
int main()
{
    long long a, b, c, n;
    zu k;
    cin >> a >> b >> c;
    vector<zu>p;
    while (a != -1 && b != -1 && c != -1)
    {
        k.a = a;
        k.b = b;
        k.c = c;
        k.n = vo(a, b, c);
        p.push_back(k);
        cin >> a >> b >> c;
    }
    for (int i = 0; i < p.size(); i++)
    {
        printf("w(%lld, %lld, %lld) = ", p[i].a, p[i].b, p[i].c);
        printf("%lld\n", p[i].n);
    }
    system("pause");
    return 0;
}

|