Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
又出错……哪位牛人帮忙瞧瞧,感激不尽!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator