回复:(crackerwang)第十八期编程比赛
comments about the problem at whu.edu.cn:
the answer is C(2n, n)/(n+1). (you may have to change n to n+1 or n-1).
Reason: for n nodes, you can have C(2n, n)/(n+1) different binary search trees.
C(2n, n)/(n+1) is called the Catlan number, if I did not remember wrong.
This problem is esentially the same as #1522 at nku.edu.cn. Following is my submission at nku:
main(){int n,i,n2,c=0;long long r;while(scanf(\"%d\",&n)!=-1){++c;r=1;n2=(n<<1);for(i=1;i<=n;++i){r*=(n2-i+1);r/=i;}r/=(n+1);printf(\"Case %d:\n\",c);printf(\"%lld\n\",r);}}
I am working on a system which has no Chinese input. Please don\'t blame me for typing English.