ACM篇:Uva 1942-- Paths on a Grid

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;

unsigned _c(unsigned m, unsigned n)
{
    double ret = 1.0;
    while (m > 0)
        ret *= (double)(n--) / double(m--);
    return (unsigned)(ret+0.5);
}
int main()
{
    unsigned x, y;
    while (scanf("%d%d", &x, &y) && (x || y))
        printf("%d\n", _c(min(x, y), x + y));
    return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章