记忆化搜索
#include<bits/stdc++.h>
using namespace std;
long long s[30][30][30];
long long f(long long x,long long y,long long z)
{
if(x<=0||y<=0||z<=0)
return 1;
if(x>20||y>20||z>20)
return f(20,20,20);
if(s[x][y][z]!=0)
return s[x][y][z];
if(x<y&&y<z)
{
s[x][y][z]=f(x,y,z-1)+f(x,y-1,z-1)-f(x,y-1,z);
}
else
{
s[x][y][z]=f(x-1,y,z)+f(x-1,y-1,z)+f(x-1,y,z-1)-f(x-1,y-1,z-1);
}
return s[x][y][z];
}
int main()
{
long long a,b,c;
while(~scanf("%lld%lld%lld",&a,&b,&c))
{
if(a==-1&&b==-1&&c==-1)
break;
printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,f(a,b,c));
}
return 0;
}