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

0ms过

Posted by jqw at 2012-01-30 15:12:31 on Problem 1579
#include<iostream>
using namespace std;
int w[22][22][22];
void solve()
{
	int i,j,k;
	for(i=1;i<21;i++)
		for(j=1;j<21;j++)
			for(k=1;k<21;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];
}
int main()
{
	int i,j,k;
	for(i=0;i<21;i++)
		for(j=0;j<21;j++)
			for(k=0;k<21;k++)
				w[i][j][k]=1;
	solve();
	while(scanf("%d %d %d",&i,&j,&k)!=EOF)
	{
		if(i==-1&&j==-1&&k==-1) break;
		printf("w(%d, %d, %d) = ",i,j,k);
		if(i<=0||j<=0||k<=0) printf("1\n");
		else if(i>20||j>20||k>20) printf("%d\n",w[20][20][20]);
		else printf("%d\n",w[i][j][k]);
	}
	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