yzsy25071621 @ 2023-08-15 20:39:16
对了数组开这么大应该没事
#include <iostream>
#include <cstring>
using namespace std;
typedef long long LL;
LL w(LL, LL, LL);
LL dataOfFunc[128][128][128];
LL a,b,c;
int main()
{
memset(dataOfFunc,-1,sizeof(dataOfFunc));
for(int i=0; i<=21; i++)
{
for(int j=0; j<=21; j++)
{
for(int k=0; k<=21; k++)
{
dataOfFunc[i][j][k]=w(i,j,k);
}
}
}
do
{
cin>>a>>b>>c;
if(a!=-1 || b!=-1 || c!=-1)
{
printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,w(a,b,c));
}
}
while(a!=-1 || b!=-1 || c!=-1);
return 0;
}
LL w(LL x, LL y, LL z)
{
if(x<=0 || y<=0 || z<=0)
{
return 1;
}
if(dataOfFunc[x][y][z]==-1)
{
if(x>20 || y>20 || z>20)
{
dataOfFunc[x][y][z]=w(20,20,20);
}
else if(x<y && y<z)
{
dataOfFunc[x][y][z]=(w(x,y,z-1)+w(x,y-1,z-1)-w(x,y-1,z));
}
else
{
dataOfFunc[x][y][z]=(w(x-1,y,z)+w(x-1,y-1,z)+w(x-1,y,z-1)-w(x-1,y-1,z-1));
}
}
return dataOfFunc[x][y][z];
}
by Elairin176 @ 2023-08-15 20:58:27
@yzsy25071621
by yzsy25071621 @ 2023-08-15 21:08:10
@destructor 那不就return 1;
by Elairin176 @ 2023-08-15 21:09:33
@yzsy25071621 哦看错了,抱歉
by Elairin176 @ 2023-08-15 21:10:21
@yzsy25071621 注意:输入的
by yzsy25071621 @ 2023-08-15 21:17:03
@destructor 已A3Q