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 xcl119xcl at 2007-07-28 16:06:10 on Problem 1579
In Reply To:w[i][j][k] = w[i][j][j-1] + w[i][j-1][k-1] - w[i][j-1][k]; Posted by:bdwyg at 2006-08-16 16:51:43
#include <iostream>
using namespace std;

int v[21][21][21]={-1};

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

int main()
{
	int a,b,c;
	int i,j,k;
	for(i=0;i<21;i++)
 		for(j=0;j<21;j++)
 			v[0][i][j] = v[i][0][j] = v[i][j][0] = 1;
	for( i=1;i<21;i++)
		for( j=1;j<21;j++)
			for( k=1;k<21;k++)
				if((i<j)&&(j<k))
 					v[i][j][k] = v[i][j][j-1] + v[i][j-1][k-1] - v[i][j-1][k];
 				else
 					v[i][j][k]=v[i-1][j][k]+v[i-1][j-1][k]+v[i-1][j][k-1]-v[i-1][j-1][k-1];
	while(cin>>a>>b>>c)
	{
		
		if(w(a,b,c))
			cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<w(a,b,c)<<endl;
			//printf("w(%d, %d, %d) = %d\n",a,b,c,w(a,b,c));
		else
			break;
				
	}
	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