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,测试数据都OK:)

Posted by plator at 2007-07-02 23:27:20 on Problem 1579
#include<iostream>
using namespace std;

int main()
{
	int w[21][21][21];
	int a,b,c;
	int i,j,k;
	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(cin>>a>>b>>c)
	{
		if(a==-1 && b==-1 && c==-1)
			return 0;
		if(a<0 || b<0 || c<=0)
		{
			cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<1<<endl;
			continue;
		}
		if(a>20 || b>20 || c>20)
		{
			a=b=c=20;
		}
		for(i=1;i<=a;i++)
		{
			for(j=1;j<=b;j++)
			{
				for(k=1;k<=c;k++)
				{
					if(i<j && j<k)
						w[i][j][k]=w[i][j][k-1]+w[i][j-1][k-1]-w[i][j-1][k];
					else
						w[i][j][k]=w[i-1][j][k]+w[i-1][j-1][k]+w[i-1][j][k-1]-w[i-1][j-1][k-1];
				}
			}
		}
		cout<<"w("<<a<<", "<<b<<", "<<c<<") = "<<w[a][b][c]<<endl;
		for(i=1;i<=a;i++)
		{
			for(j=1;j<=b;j++)
			{
				for(k=1;k<=c;k++)
					w[i][j][k]=0;
			}
		}
	}
	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