100分但是unaccepted

P1464 Function

ok077 @ 2023-09-07 16:44:35

为啥substack#0的5个测试点AC,但是substack#1的两个测试点是WA?有大佬可以指导一下吗

using namespace std;
long long data[21][21][21]={0};
long long in[10000][3];
int w(int a,int b,int c)
{

    if(a<=0||b<=0||c<=0)return 1;
    else if(a>20||b>20||c>20)return w(20,20,20);
    if(data[a][b][c]!=0)return data[a][b][c];
    else if(a<b&&b<c)data[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
    else data[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 data[a][b][c];
}
int main()
{
    int i,j,n;
    for(i=0;i<10000;i++)
    {
        for(j=0;j<3;j++)
            cin>>in[i][j];
        if(in[i][0]==-1&&in[i][1]==-1&&in[i][2]==-1)break;
        cout<<"w("<<in[i][0]<<", "<<in[i][1]<<", "<<in[i][2]<<") = "<<w(in[i][0],in[i][1],in[i][2])<<endl;
    }
    return 0;
}

by Nobelium_255 @ 2023-09-07 17:09:26

函数传参,也要开long long吧(大概


by rabbitearl @ 2023-09-19 19:34:07

一样,不知道为啥


by a1090251107 @ 2023-11-13 20:33:05

hack的输入数据是2147483648 1 1 -1 -1 -1,这里的a刚好超过了int(= =没搞懂这东西有啥意义),所以传参的时候形参要开long long这样才能在第一波递归引用的时候保证数据范围


|