POJ1942 Paths on a Grid(组合)

题目链接

分析:

#include <cstdio>
#include <iostream>
#include <map>
#include <cstring>

using namespace std;

typedef unsigned long long LL;

int main() {
    LL n, m;

    while(cin >> n >> m) {
        if(n == 0 && m == 0) break;

        LL s = n+m;
        if(n > m) swap(n, m);

        LL ans = 1;
        for(LL i=s, j=1; j<=n; i--, j++) {
            ans = ans * i/j;
        }

        cout << ans << endl;
    }

    return 0;
}

 

 

posted on 2013-08-07 16:20  Still_Raining  阅读(180)  评论(0)    收藏  举报