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

边存储边递归!好方法!

Posted by cycpp at 2008-11-19 20:12:34 on Problem 1579
In Reply To:1579这代码错在哪里,帮帮忙啊,总是Presentation Error Posted by:YBB06 at 2008-11-08 23:21:04
> #include<stdio.h>
> int p[55][55][55];
> int w(int i,int j,int k)
> {    
>      if(i<=0||j<=0||k<=0)   return 1;
> 	 if(p[i][j][k]>0)  return p[i][j][k]; 
> 	 if(i>20||j>20||k>20)    p[i][j][k]=w(20,20,20);
> 	 if(i<j&&j<k)    return  p[i][j][k]=w(i,j,k-1)+w(i,j-1,k-1)-w(i,j-1,k);
> 	 else     return p[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 a,b,s,c;
>     int i,j,k;
>     while(scanf("%d%d%d",&a,&b,&c)&&a!=-1||b!=-1||c!=-1)
> 	{        
> 		for(i=0;i<a;i++)
> 			for(j=0;j<b;j++)
> 				for(k=0;k<c;k++)
> 					if(i==0||j==0||k==0)
> 					p[i][j][k]=-1;
> 
> 						 s=w(a,b,c);
> 					 printf("w(%d,%d,%d) = %d\n",a,b,c,s);
> 	}
> 			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