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

呵呵,1ac,纪念下呢

Posted by TSERROF at 2012-09-08 18:51:09 on Problem 1579
#include <cstdio>
#include <cstring>
int r[50][50][50];
int f(int a,int b,int c)
{
	if(a<=0 || b<=0 || c<=0)return 1;
	if(r[a][b][c])return r[a][b][c];	
	else if(a>20 || b>20 || c>20)r[a][b][c]=f(20,20,20);
	else if(a<b && b<c)r[a][b][c]=f(a,b,c-1)+f(a,b-1,c-1)-f(a,b-1,c);
	else r[a][b][c]= f(a-1, b, c) + f(a-1, b-1, c) + f(a-1, b, c-1) - f(a-1, b-1, c-1);
	return r[a][b][c];
}
int main()
{
	int a,b,c;
	memset(r,0,sizeof(r));
	while(scanf("%d%d%d",&a,&b,&c)!=EOF && (a!=-1 || b!=-1 || c!=-1))printf("w(%d, %d, %d) = %d\n",a,b,c,f(a,b,c));
}

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