我知道你是怎么错的
附上修改后的代码
```cpp
#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
int a[10001],b[10001],c[10001],d[10001],j[21][21][21];
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 (j[a][b][c]!=0) return j[a][b][c];
if (a<b&&b<c)
return j[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
else
return j[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);
}
int main()
{
long long x,y,z;
int s=0,i;
cin>>x>>y>>z;
while (x!=-1||y!=-1||z!=-1)
{
s++;
a[s]=x;
b[s]=y;
c[s]=z;
d[s]=w(a[s],b[s],c[s]);
cin>>x>>y>>z;
}
for (i=1;i<s;i++)
cout<<"w("<<a[i]<<", "<<b[i]<<", "<<c[i]<<") = "<<d[i]<<" "<<endl;
cout<<"w("<<a[s]<<", "<<b[s]<<", "<<c[s]<<") = "<<d[s];
return 0;
}
```
你在记忆化搜索的时候
```cpp
if (a<b&&b<c)
{
j[a][b][c-1]=w(a,b,c-1);
j[a][b-1][c-1]=w(a,b-1,c-1);
j[a][b-1][c]=w(a,b-1,c);
return (j[a][b][c-1]+j[a][b-1][c-1]-j[a][b-1][c]);
}
else
{
j[a-1][b][c]=w(a-1,b,c);
j[a-1][b-1][c]=w(a-1,b-1,c);
j[a-1][b][c-1]=w(a-1,b,c-1);
j[a-1][b-1][c-1]=w(a-1,b-1,c-1);
return (j[a-1][b][c]+j[a-1][b][c]+j[a-1][b][c-1]-j[a-1][b-1][c-1]);
}
```
这个语句中 记忆的是他下一层的值 实际上他自己的值也算出来了 像我那样写就会把当前所有算出来的值都记忆下来
AC
by ztzshiwo001219 @ 2016-08-04 11:42:01
谢谢了@ztzshiwo001219
by 王小宇 @ 2016-08-05 05:56:34
@ ztzshiwo001219
by 王小宇 @ 2016-08-05 05:57:11
话说这个@的格式到底怎么写啊
by 王小宇 @ 2016-08-05 05:57:51
谢谢@[ztzshiwo001219](/space/show?uid=8462)
by 王小宇 @ 2016-08-05 06:02:58