简单的组合题:


#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; }