题目:P1464 Function
by M_Train @ 2023-12-17 15:54:01
@[M_Train](/user/906777) 放个代码?
by xiaoshumiao @ 2023-12-17 16:04:53
发不了!!!
by M_Train @ 2023-12-17 19:29:34
```cpp
#include<iostream>
using namespace std;
long long f[25][25][25];
long long w(long long a,long long b,long long c)
{
if(a<=0||b<=0||c<=0) return 1;
else if(a>20||b>20||c>20) return w(20,20,20);
else if(f[a][b][c]!=0) return f[a][b][c];
else if(a<b&&b<c)
f[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)+w(a,b-1,c);
else
f[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a,b,c-1)+w(a-1,b-1,c-1);
return f[a][b][c];
}
int main()
{
long long a,b,c;
while (cin>>a>>b>>c){
if(a==-1&&b==-1&&c==-1)
break;
cout<<"w("<< a<< ", "<<b<<", "<<c<<") = ";
cout<<w(a,b,c)<<endl;
}
return 0;
}
```
by M_Train @ 2023-12-17 19:34:32
@[xiaoshumiao](/user/1008513)
好了!
by M_Train @ 2023-12-17 19:35:21
@[M_Train](/user/906777) 仔细读题。递归调用时有一些减号你打成了加号。
by xiaoshumiao @ 2023-12-17 20:08:31
```cpp
#include<iostream>
using namespace std;
long long f[25][25][25];
long long w(long long a,long long b,long long c)
{
if(a<=0||b<=0||c<=0) return 1;
else if(a>20||b>20||c>20) return w(20,20,20);
else if(f[a][b][c]!=0) return f[a][b][c];
else if(a<b&&b<c)
f[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)+w(a,b-1,c);
else
f[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a,b,c-1)+w(a-1,b-1,c-1);
return f[a][b][c];
}
int main()
{
long long a,b,c;
while (cin>>a>>b>>c){
if(a==-1&&b==-1&&c==-1)
break;
cout<<"w("<< a<< ", "<<b<<", "<<c<<") = ";
cout<<w(a,b,c)<<endl;
}
return 0;
}
```
------------
改了也不行
by M_Train @ 2023-12-17 21:04:14