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

我的100道留念。。。(附代码)。。。。

Posted by 806601756 at 2011-07-26 10:16:30 on Problem 1579
#include <stdio.h>
#include <memory.h>

int v[21][21][21];

int w(int a,int b,int c)
{
	if(a<=0||b<=0||c<=0)return 1;
	if(a>20||b>20||c>20)return w(20,20,20);
	if(v[a][b][c]!=-1)return v[a][b][c];
	if(a<b&&b<c)
	{
		v[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
	}
	else 
	{
		v[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
	}
	return v[a][b][c];
}

int main()
{
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c)!=EOF)
	{
		memset(v,-1,sizeof(v));
		if(a==-1&&b==-1&&c==-1)
			break;
		else
		{
			printf("w(%d, %d, %d) = %d\n",a,b,c,w(a,b,c));
		}
	}
	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