@[HeTaiyu](/space/show?uid=131970)
你把a b c强制转换成int,会把数字改变的。
人家本来是long long 类型,干嘛改成int
by k,火魂 @ 2019-08-22 10:55:00
@[HeTaiyu](/space/show?uid=131970)
我给你改对了,就是int错了,还有就是你打错了一句
```cpp
#include<iostream>
#include<string.h>
using namespace std;
#define nil -250;
#define ll long long
int mem[21][21][21];
struct output{
long long a,b,c;
int ans;
}buffer[600];
short pbuf = 0;
int w(ll a,ll b,ll c){
//cout<<a<<','<<b<<','<<c<<' ';
//cout<<"mem:"<<mem[a][b][c]<<' ';
if(a<=0 || b<=0 || c<=0){
//cout<<"return 1"<<endl;
return 1;
}
if(a>20 or b>20 or c>20){
//cout<<"return w(20,20,20)"<<endl;
return w(20,20,20);
}
if( mem[a][b][c]!=-256 ){
//cout<<"return mem"<<endl;
return mem[a][b][c];
}
if(a<b && b<c){
mem[a][b][c]= w(a,b,c-1) +
//这里你忘了加w了,注意一点
w(a,b-1,c-1)-w(a,b-1,c);
return mem[a][b][c];
}
//cout<<"compute"<<endl;
mem[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 mem[a][b][c];
}
int main(){
//freopen("cnm.out","w",stdout);
for(int i=0;i<21;i++)
for(int j=0;j<21;j++)
for(int k=0;k<21;k++)
mem[i][j][k]=-256;
long long a=0,b=0,c=0;
while(1){
a=0,b=0,c=0;
cin>>a>>b>>c;
if(a==-1&&b==-1&&c==-1) break;
buffer[pbuf].a=a;
buffer[pbuf].b=b;
buffer[pbuf].c=c;
buffer[pbuf].ans=w(a,b,c);
pbuf++;
//cout<<"w("<<a<<','<<b<<','<<c<<") = ";
//cout<<w(int(a),int(b),int(c))<<endl;
}
int i=0;
while(pbuf--){
cout<<"w("<<buffer[i].a<<", "<<buffer[i].b<<", "<<buffer[i].c<<") = ";
cout<<buffer[i].ans<<endl;
i++;
}
return 0;
}
```
by k,火魂 @ 2019-08-22 11:08:52
@[k,火魂](/space/show?uid=169137) 非常感谢!
by HeTaiyu @ 2019-08-22 19:08:04