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 |
Re:这题有公式么?用的什么知识?In Reply To:这题有公式么?用的什么知识? Posted by:billmaths at 2005-03-22 22:55:09 #include<stdio.h> int main() { __int64 a[19][201]; int i,j,k,n,kk,m,h; memset(a,0,sizeof(a)); for(i=1;i<=18;i++) { a[i][0]=1; a[i][i*(i-1)/2]=1; if(i>1) a[i][1]=a[i][i*(i-1)/2-1]=i-1; //rev[n][1]=rev[n][m-1]=n-1; } for(i=2; i<=18; ++i) { m=i*(i-1)/2; for(j=2; j<m-1; ++j) for(k=j,h=0;h<i;--k,h++) a[i][j]+=a[i-1][k]; } while(scanf("%d%d",&n,&kk)!=EOF&&(n||kk)) { printf("%I64d\n",a[n][kk]); } return 0; } /* 3 0 3 1 3 2 3 3 4 2 4 10 13 23 18 80 0 0 1 2 2 1 5 0 46936280 184348859235088 */ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator