#include<bits/stdc++.h>
#define ll unsigned long long int
using namespace std;
ll combination(ll n, ll k)
{
if(k == 0)
return 1;
if(k>n)
return 0;
if(k*2 > n)
k = n - k;
ll r = n, i;
return r;
}
int main()
{
ll n, m;
//where n is n and m is r = nCr;
while(cin >> n >> m)
{
ll r = combination(n, m);
cout << r << endl;
}
return 0;
}
#define ll unsigned long long int
using namespace std;
ll combination(ll n, ll k)
{
if(k == 0)
return 1;
if(k>n)
return 0;
if(k*2 > n)
k = n - k;
ll r = n, i;
for(i=2;i<=k;i++)
{
r *= (n-i+1);
r /= i;
}
{
r *= (n-i+1);
r /= i;
}
return r;
}
int main()
{
ll n, m;
//where n is n and m is r = nCr;
while(cin >> n >> m)
{
ll r = combination(n, m);
cout << r << endl;
}
return 0;
}
Comments
Post a Comment