您的位置:首页 > 其它

poj 1942 Paths on a Grid

2012-08-13 10:40 399 查看
简单的组合题:

View Code

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<vector>
#include<string>
#define LL long long
using namespace std;
LL Gcd( LL a, LL b )
{
return b ==0 ? a : Gcd( b , a % b );
}
LL Get_C( LL n ,LL m )
{
LL ans = 1,ans1 = 1;
while( m )
{
ans *= n;
ans1 *=m;
LL t = Gcd( ans ,  ans1 );
ans /= t;
ans1 /= t;
n --;
m --;
}
return ans/ans1;
}
int main(  )
{
LL n,m;
while( scanf( "%I64d %I64d",&n,&m ),n|m )
{
printf( "%I64d\n",Get_C( n+m ,min( n , m ) ) );
}
//system( "pause" );
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: