#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;
LL a,b,c;
LL g[22][22][22];

LL Solve(LL a,LL b,LL c){
	if(a<=0||b<=0||c<=0) return 1;
	a=a>20?21:a;
	b=b>20?21:b;
	c=c>20?21:c;
	if(g[a][b][c]!=-1) return g[a][b][c];
	if(a>20||b>20||c>20) return g[a][b][c]=Solve(20,20,20);
	if(a<b&&b<c) return g[a][b][c]=Solve(a,b,c-1)+Solve(a,b-1,c-1)-Solve(a,b-1,c);
	return g[a][b][c]=Solve(a-1,b,c)+Solve(a-1,b-1,c)+Solve(a-1,b,c-1)-Solve(a-1,b-1,c-1);
}

int main(){
	memset(g,-1,sizeof(g));
	while(~scanf("%lld%lld%lld",&a,&b,&c)){
		if(a==-1&&b==-1&&c==-1) return 0;
		printf("w(%lld, %lld, %lld) = %lld\n",a,b,c,Solve(a,b,c));
	}
	return 0;
}

 

0 0 votes
文章评分

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

0 评论
Inline Feedbacks
View all comments