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

int s[MAXNUMBER][MAXNUMBER]——〉int s[MAXNUMBER][MAXNUMBER];

Posted by Loger at 2004-04-27 11:44:00 on Problem 1221
In Reply To:又出错……哪位牛人帮忙瞧瞧,感激不尽! Posted by:C0400104048 at 2004-04-24 01:05:28
> #include<stdio.h>
> #define MAXNUMBER 501
> 
> main()
> {int s[MAXNUMBER][MAXNUMBER];
>  int max_num,n,i,j,k,sum;
>  for(i=1;i<MAXNUMBER;i++)
> 	 s[i][0]=1;
>  s[1][1]=1;
>  max_num=1;
>  while(1)
>  {   scanf("%d",&n);
>      if(n==0)break;
> 	 if(n<=max_num)
> 	 {   printf("%d %d\n",n,s[n][0]);continue;
> 	 }
> 	 for(i=max_num+1;i<=n;i++)
> 	 {   
> 		 for(j=1;j<=i-1;j++)
> 		 {   
> 			 if(i-j*2<0)s[i][j]=0;
> 			 else if(i-j*2==0)s[i][j]=1;
> 			 else
> 			 {   sum=i-j*2;
> 			     for(s[i][j]=0,k=j;k<=sum;k++)
> 				     s[i][j]+=s[sum][k];
> 			 }
> 			 s[i][0]=s[i][0]+s[i][j];
> 		 }
> 		 s[i][i]=1;
> 	 }
> 	 max_num=n;
> 	 printf("%d %d\n",n,s[n][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