zrq495
www.zrq495.com

代码:

 1 #include<iostream>
 2 
 3 using namespace std;
 4 
 5 long long comb(long long m, long long n)
 6 {
 7     long long s=1;
 8     m=n-m>m?m:n-m;
 9     long long k=1, i;
10     for (i=0; i<m; i++)
11     {
12         s*=n-i;
13         while(k <=m && s%k==0)
14         {
15             s/=k;
16             k++;
17         }
18     }
19     return s;
20 }
21 
22 int main()
23 {
24     long long a, b;
25     while(cin >> a >> b, a || b)
26     {
27         cout << comb(a, a+b) << endl;
28     }
29     return 0;
30 }
posted on 2012-07-31 13:59  zrq495  阅读(267)  评论(0编辑  收藏  举报