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 ckg081910 at 2013-05-01 22:07:54 on Problem 1579
#include <stdio.h>
int dp[21][21][21];
int main(){
	int a,b,c,i,j,k,m,n,p;
	for(i=0;i<=21;i++)
		for(j=0;j<=21;j++)
		{
			dp[0][i][j]=1;
			dp[i][0][j]=1;
			dp[i][j][0]=1;
		}
	while(scanf("%d%d%d",&a,&b,&c)&&(a!=-1||b!=-1||c!=-1)){
		m=a;
		n=b;
		p=c;
		if(m<=0||n<=0||p<=0)
		{
			m=0;
			n=0;
			p=0;
		}
		else if(m>20||n>20||p>20)
		{
			m=20;
			n=20;
			p=20;
		}
		for(i=1;i<=m;i++)
			for(j=1;j<=n;j++)
				for(k=1;k<=p;k++){
					if(i<j&&j<k)
						dp[i][j][k]=dp[i][j][k-1]+dp[i][j-1][k-1]-dp[i][j-1][k];
					else
						dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k]+dp[i-1][j][k-1]-dp[i-1][j-1][k-1];
				}
		printf("w(%d, %d, %d) = %d\n",a,b,c,dp[m][n][p]);
	}
	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