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

Why,WA?

Posted by Alexande at 2006-05-24 19:56:45 on Problem 1579
#include  <stdio.h>
#define max 22
int data[max][max][max];
void main()
{
  
  int i,j,k;
  for(i=0;i<21;i++)
	  for(j=0;j<21;j++)
	  {
		  data[0][i][j]=1;
		  data[i][0][j]=1;
		  data[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))
				data[i][j][k]=data[i][j][k-1] + data[i][j-1][k-1] - data[i][j-1][k];
			else
			    data[i][j][k]=data[i-1][j][k] + data[i-1][j-1][k] + data[i-1][j][k-1] -data[i-1][j-1][k-1];
		  }
  int a,b,c;
 while(1)
  { 
	scanf("%d %d %d",&a,&b,&c);
	if((a==-1)&&(b==-1)&&(c==-1))
		break;
	printf("w(%d, %d, %d) = ",a,b,c);  
         if(a>20||b>20||c>20)
                  printf("%d\n",data[20][20][20]);
	else if(a<=0||b<=0||c<=0)
		printf("1\n");
	else
		printf("%d\n",data[a][b][c]);
  }


}

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