为什么是100分还有错!!

P1464 Function

yang1812 @ 2024-03-07 22:15:22

#include<bits/stdc++.h>
using namespace std;

int a,b,c;
int l[21][21][21] = {0};
int w(int a ,int b , int c){
    if(a <= 0 || b <= 0 || c <= 0){
        return 1;
    }
    if(a > 20 || b > 20 || c > 20){
        return w(20 , 20 , 20);
    }
    if(l[a][b][c] != 0){
        return l[a][b][c];
    }
    if(a < b && b < c){
        l[a][b][c] = w(a,b,c - 1) + w(a,b - 1,c - 1) - w(a,b - 1,c);
    }
    if(a < b && b < c){
        l[a][b][c] = w(a,b,c - 1) + w(a,b - 1,c - 1) - w(a,b - 1,c);
    }else{
        l[a][b][c] = w(a - 1,b,c) + w(a - 1,b - 1,c) + w(a - 1,b,c - 1) - w(a - 1,b - 1,c - 1);
    }
    return l[a][b][c];
}

int main(){
    while(true){
        scanf("%d%d%d",&a,&b,&c);
        if(a == -1 && b == -1 && c == -1){
            break;
        }
        printf("w(%d, %d, %d) = %d\n",a,b,c,w(a,b,c));
    }
    return 0;
}

by damnM3bro @ 2024-03-07 22:16:46

@yang1812 没开 long long


|