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

为什么在pku通过了在zju却超时??

Posted by tbaitm at 2005-12-11 01:08:24 on Problem 1579
#include<iostream>
//#include<fstream>

using namespace std;

int main()
{
	//ifstream cin("source.txt");
	long i,j,k,w[21][21][21]={0};
	
	for(i=0;i<21;i++)
		for(j=0;j<21;j++)
			w[0][i][j] = w[i][0][j] = w[i][j][0] = 1;

	for(i=1;i<=20;i++)
		for(j=1;j<=20;j++)
			for(k=1;k<=20;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];
					  
	while(cin>>i>>j>>k)
	{
		if(-1==i&&-1==j&&-1==k)break;
	    if(i<=0||j<=0||k<=0)
		{
			cout<<"w("<<i<<", "<<j<<", "<<k<<") = "<<1<<endl;
			continue;
		}
        if(i>20||j>20||k>20)
		{
			cout<<"w("<<i<<", "<<j<<", "<<k<<") = "<<w[20][20][20]<<endl;
			continue;
		}
		cout<<"w("<<i<<", "<<j<<", "<<k<<") = "<<w[i][j][k]<<endl;
	}

	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