Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

wa

Posted by lcy1988 at 2008-08-02 17:53:43 on Problem 1579
#include<stdio.h>
int w[21][21][21],i,j,k;
int ww(int a,int b,int c)
{
	if(w[a][b][c]!=-1) return w[a][b][c];
	for(i=0;i<=20;i++)
		for(j=0;j<=20;j++)
			for(k=0;k<=20;k++)
				if(i<j&&j<k)
					w[i][j][k]=ww(i,j,k-1)+ww(i,j-1,k-1)-ww(i,j-1,k);
				else
					w[i][j][k]=ww(i-1,j,k)+ww(i-1,j-1,k)+ww(i-1,j,k-1)-ww(i-1,j-1,-1);
	return w[a][b][c];
} 
int main()
{
	for(i=0;i<=20;i++)
		for(j=0;j<=20;j++)
			for(k=0;k<=20;k++)
				w[i][j][k]=-1;
	for(i=0;i<=20;i++)
		for(j=0;j<=20;j++)
		{
			w[0][i][j]=1;
			w[i][0][j]=1;
			w[i][j][0]=1;
		}
	while(scanf("%d%d%d",&i,&j,&k)&&i!=-1)
	{
		printf("w(%d, %d, %d) = ",i,j,k);
		if(i<0||i==0||j<0||j==0||k<0||k==0)
			printf("1\n");
		else if(i>20||j>20||k>20)
			printf("%d\n",ww(20,20,20));
		else
			printf("%d\n",ww(i,j,k));
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator