记忆化搜索。
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<iostream>
using namespace std; struct X{
int x,y,z;
X(int xx,int yy,int zz)
{
x=xx;
y=yy;
z=zz;
}
bool operator < (const X &a) const {
if(x!=a.x) return x>a.x;
if(y!=a.y) return y>a.y;
return z>a.z;
}
};
int a,b,c;
map<X,bool>f;
map<X,int>w; int work(int x,int y,int z)
{
if(f[X(x,y,z)]) return w[X(x,y,z)]; f[X(x,y,z)]=true;
if(x <= || y <= || z <= ) w[X(x,y,z)]=;
else if(x > || y > || z > ) w[X(x,y,z)] = work(,,);
else if(a < b && b < c) w[X(x,y,z)] =work(x, y, z-) + work(x, y-, z-) - work(x, y-, z);
else w[X(x,y,z)] = work(x-, y, z) + work(x-, y-, z) + work(x-, y, z-) - work(x-, y-, z-); return w[X(x,y,z)];
} int main()
{
while(~scanf("%d%d%d",&a,&b,&c))
{
if(a==-&&b==-&&c==-) break;
printf("w(%d, %d, %d) = %d\n",a,b,c,work(a,b,c));
} return ;
}