bowenzuo @ 2022-12-12 10:01:34
#include<cstdio>
#include<cmath>
using namespace std;
int n;
long long a,b,c;
int 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(a<b&&b<c)
{
return w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
}
else
{
return 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()
{
while(scanf("%lld%lld%lld",&a,&b,&c))
{
if(a==-1&&b==-1&&c==-1)
{
break;
}
printf("w(%lld, %lld, %lld) = %d\n",a,b,c,w(a,b,c));
}
return 0;
}
TLE哎呀妈真香
by DFSer @ 2022-12-12 10:21:37
加上记忆化搜索,题目标签里有的……
by bowenzuo @ 2022-12-12 10:25:45
@DFSer 谢谢~